<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/migration81.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'migration81.new-features.php',
    1 => 'New Features',
    2 => 'New Features',
  ),
  'up' => 
  array (
    0 => 'migration81.php',
    1 => 'Migrating from PHP 8.0.x to PHP 8.1.x',
  ),
  'prev' => 
  array (
    0 => 'migration81.php',
    1 => 'Migrating from PHP 8.0.x to PHP 8.1.x',
  ),
  'next' => 
  array (
    0 => 'migration81.new-classes.php',
    1 => 'New Classes and Interfaces',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'appendices/migration81/new-features.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="migration81.new-features" class="sect1">
 <h2 class="title">New Features</h2>

 <div class="sect2" id="migration81.new-features.core">
  <h3 class="title">PHP Core</h3>

  <div class="sect3" id="migration81.new-features.core.octal-literal-prefix">
   <h4 class="title">Integer Octal Literal Prefix</h4>

   <p class="para">
    Octal integers can now use an explicit
    <code class="literal">0o</code>/<code class="literal">0O</code>
    prefix in integer literals,
    similarly to binary and hexadecimal integer literals.
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />014</span><span style="color: #007700">;  </span><span style="color: #FF8000">// Non-prefix octal literal<br /></span><span style="color: #0000BB">0o14</span><span style="color: #007700">; </span><span style="color: #FF8000">// Prefixed octal literal<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
   
  </div>

  <div class="sect3" id="migration81.new-features.core.unpacking-string-keys">
   <h4 class="title">Array Unpacking with String Keys</h4>

   <p class="para">
    Added support for <a href="language.types.array.php#language.types.array.unpacking" class="link">array unpacking with strings keys</a>.
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$arr1 </span><span style="color: #007700">= [</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #DD0000">'a' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'b'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">$arr2 </span><span style="color: #007700">= [...</span><span style="color: #0000BB">$arr1</span><span style="color: #007700">, </span><span style="color: #DD0000">'c' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'d'</span><span style="color: #007700">]; </span><span style="color: #FF8000">//[1, 'a' =&gt; 'b', 'c' =&gt; 'd']<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
   
  </div>

  <div class="sect3" id="migration81.new-features.core.named-arg-after-unpack">
   <h4 class="title">Named Argument After Argument Unpacking</h4>

   <p class="para">
    It is now possible to specify named arguments after an argument unpack.
    
    e.g.
    foo(...$args, named: $arg).
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.core.upload-full-path-key">
   <h4 class="title">full-path Key for File Uploads</h4>

   <p class="para">
    File uploads now provide an additional <code class="literal">full_path</code> key,
    which contains the full path (rather than just the basename) of the uploaded file.
    This is intended for use in conjunction with &quot;upload webkitdirectory&quot;.
   </p>
   
  </div>

  <div class="sect3" id="migration81.new-features.core.enums">
   <h4 class="title">Enumerations</h4>

   <p class="para">
    Support for <a href="language.enumerations.php" class="link">Enumerations</a> has been added.
    
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.core.fibers">
   <h4 class="title">Fibers</h4>

   <p class="para">
    Support for <a href="language.fibers.php" class="link">Fibers</a> has been added.
    
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.core.callable-syntax">
   <h4 class="title">First Class Callable Syntax</h4>

   <p class="para">
    Closures for callables can now be created using <a href="functions.first_class_callable_syntax.php" class="link">the syntax <code class="code">myFunc(...)</code></a>,
    which is identical to <code class="code">Closure::fromCallable(&#039;myFunc&#039;)</code>.
    
   </p>
   <blockquote class="note"><p><strong class="note">Nota</strong>: 
    <span class="simpara">
     The <code class="code">...</code> is part of the syntax, and not an omission.
    </span>
   </p></blockquote>
  </div>

  <div class="sect3" id="migration81.new-features.core.intersection-types">
   <h4 class="title">Intersection Types</h4>

   <p class="para">
    Support for <a href="language.types.type-system.php#language.types.type-system.composite.intersection" class="link">intersection types</a> has been added.
    
   </p>
   <div class="caution"><strong class="caution">Attenzione</strong>
    <p class="simpara">
     <a href="language.types.type-system.php#language.types.type-system.composite.intersection" class="link">
      Intersection types</a> cannot be used together with
     <a href="language.types.declarations.php#language.types.declarations.composite.union" class="link">
      union types</a>
    </p>
   </div>
  </div>

  <div class="sect3" id="migration81.new-features.core.never-type">
   <h4 class="title">Never type</h4>

   <p class="para">
    A new return only type <span class="type"><a href="language.types.never.php" class="type never">never</a></span> has been added.
    This indicates that a function either <span class="function"><a href="function.exit.php" class="function">exit()</a></span>,
    throws an exception, or doesn&#039;t terminate.
    
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.core.new-in-initializer">
   <h4 class="title"><a href="language.oop5.basic.php#language.oop5.basic.new" class="link"><code class="literal">new</code></a> in Initializers</h4>

   <p class="para">
    It is now possible to use <code class="code">new ClassName()</code> expressions as the
    default value of a parameter, static variable, global constant initializers,
    and as attribute arguments.
    Objects can also be passed to <span class="function"><a href="function.define.php" class="function">define()</a></span> now.
    
   </p>
   
  </div>

  <div class="sect3" id="migration81.new-features.core.readonly">
   <h4 class="title">Readonly properties</h4>

   <p class="para">
    Support for <a href="language.oop5.properties.php#language.oop5.properties.readonly-properties" class="link">readonly</a> has been added.
    
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.core.final-constants">
   <h4 class="title">Final class constants</h4>

   <p class="para">
    Added support for <a href="language.oop5.final.php#language.oop5.final.example.php81" class="link">the <span class="modifier">final</span> modifier for class constants</a>.
    Also, interface constants become overridable by default.
    
   </p>
  </div>

 </div>

 <div class="sect2" id="migration81.new-features.curl">
  <h3 class="title">CURL</h3>

  <p class="para">
   Added the <strong><code><a href="curl.constants.php#constant.curlopt-doh-url">CURLOPT_DOH_URL</a></code></strong> option.
  </p>

  <p class="para">
   Added options for blob certificate when libcurl &gt;= 7.71.0:
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-issuercert-blob">CURLOPT_ISSUERCERT_BLOB</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-proxy-issuercert">CURLOPT_PROXY_ISSUERCERT</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-proxy-issuercert-blob">CURLOPT_PROXY_ISSUERCERT_BLOB</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-proxy-sslcert-blob">CURLOPT_PROXY_SSLCERT_BLOB</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-proxy-sslkey-blob">CURLOPT_PROXY_SSLKEY_BLOB</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-sslcert-blob">CURLOPT_SSLCERT_BLOB</a></code></strong></span>
   </li>
   <li class="listitem">
    <span class="simpara"><strong><code><a href="curl.constants.php#constant.curlopt-sslkey-blob">CURLOPT_SSLKEY_BLOB</a></code></strong></span>
   </li>
  </ul>

  <p class="para">
   Added <span class="classname"><a href="class.curlstringfile.php" class="classname">CURLStringFile</a></span>, which can be used to post
   a file from a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> rather than a file:
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$file </span><span style="color: #007700">= new </span><span style="color: #0000BB">CURLStringFile</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #DD0000">'filename.txt'</span><span style="color: #007700">, </span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$curl</span><span style="color: #007700">, </span><span style="color: #0000BB">CURLOPT_POSTFIELDS</span><span style="color: #007700">, [</span><span style="color: #DD0000">'file' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$file</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.fpm">
  <h3 class="title">FPM</h3>

  <p class="para">
   Added openmetrics status format. It can be used by Prometheus to fetch FPM
   metrics.
  </p>
  <p class="para">
   Added new pool option for the dynamic process manager called
   <code class="literal">pm.max_spawn_rate</code>. It allows to start a number of children
   at a faster rate when dynamic pm is selected.
   The default value is <code class="literal">32</code> which was the previous
   hard coded value.
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.gd">
  <h3 class="title">GD</h3>

  <p class="para">
   Avif support is now available through
   <span class="function"><a href="function.imagecreatefromavif.php" class="function">imagecreatefromavif()</a></span> and
   <span class="function"><a href="function.imageavif.php" class="function">imageavif()</a></span>,
   if libgd has been built with Avif support.
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.hash">
  <h3 class="title">Hash</h3>

  <p class="para">
   The following functions <span class="function"><a href="function.hash.php" class="function">hash()</a></span>,
   <span class="function"><a href="function.hash-file.php" class="function">hash_file()</a></span>, and <span class="function"><a href="function.hash-init.php" class="function">hash_init()</a></span>
   now support an additional optional <code class="parameter">options</code>
   argument, which can be used to pass algorithm specific data.
  </p>

  <div class="sect3" id="migration81.new-features.hash.murmurhash3">
   <h4 class="title">MurmurHash3</h4>

   <p class="para">
    Added support for <code class="literal">MurmurHash3</code> with streaming
    support. The following variants are implemented:
   </p>
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">murmur3a, 32-bit hash</span>
    </li>
    <li class="listitem">
     <span class="simpara">murmur3c, 128-bit hash for x86</span>
    </li>
    <li class="listitem">
     <span class="simpara">murmur3f, 128-bit hash for x64</span>
    </li>
   </ul>

   <p class="para">
    The initial hash state can be passed through the <code class="literal">seed</code>
    key in the <code class="parameter">options</code> array, for example:

    <div class="informalexample">
     <div class="example-contents">
      <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$h </span><span style="color: #007700">= </span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">"murmur3f"</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">options</span><span style="color: #007700">: [</span><span style="color: #DD0000">"seed" </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">42</span><span style="color: #007700">]);<br />echo </span><span style="color: #0000BB">$h</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>

    A valid seed value is within the range from <code class="literal">0</code>
    to the platform defined <strong><code>UINT_MAX</code></strong>, usually
    <code class="literal">4294967295</code>.
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.hash.xxhash">
   <h4 class="title">xxHash</h4>

   <p class="para">
    Added support for <code class="literal">xxHash</code>.
    The following variants are implemented:
   </p>
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">xxh32, 32-bit hash</span>
    </li>
    <li class="listitem">
     <span class="simpara">xxh64, 64-bit hash</span>
    </li>
    <li class="listitem">
     <span class="simpara">xxh3, 64-bit hash</span>
    </li>
    <li class="listitem">
     <span class="simpara">xxh128, 128-bit hash</span>
    </li>
   </ul>

   <p class="para">
    The initial hash state can be passed through the <code class="literal">seed</code>
    key in the <code class="parameter">options</code> array, for example:

    <div class="informalexample">
     <div class="example-contents">
      <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$h </span><span style="color: #007700">= </span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">"xxh3"</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">options</span><span style="color: #007700">: [</span><span style="color: #DD0000">"seed" </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">42</span><span style="color: #007700">]);<br />echo </span><span style="color: #0000BB">$h</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>

    Secret usage is supported through passing the <code class="literal">secret</code>
    key in the <code class="parameter">options</code> array, too:

    <div class="informalexample">
     <div class="example-contents">
      <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$h </span><span style="color: #007700">= </span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">"xxh3"</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">options</span><span style="color: #007700">: [</span><span style="color: #DD0000">"secret" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"at least 136 bytes long secret here"</span><span style="color: #007700">]);<br />echo </span><span style="color: #0000BB">$h</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>

    The quality of the custom secret is crucial for the quality of the resulting hash.
    It is highly recommended for the secret to use the best possible entropy.
   </p>
  </div>
 </div>

 <div class="sect2" id="migration81.new-features.mysqli">
  <h3 class="title">MySQLi</h3>

  <div class="sect3" id="migration81.new-features.mysqli.local_infile_directory">
   <h4 class="title">New INI directive <code class="literal">mysqli.local_infile_directory</code></h4>

   <p class="para">
    The <a href="mysqli.configuration.php#ini.mysqli.local-infile-directory" class="link">mysqli.local_infile_directory</a>
    INI directive has been added, which can be used to specify a directory from
    which files are allowed to be loaded. It is only meaningful if
    <a href="mysqli.configuration.php#ini.mysqli.allow-local-infile" class="link">mysqli.allow_local_infile</a>
    is not enabled, as all directories are allowed in that case.
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.mysqli.bind-in-execute">
   <h4 class="title">Binding parameters in execute</h4>

   <p class="para">
    It is now possible to bind parameters by passing them as an array to
    <span class="methodname"><a href="mysqli-stmt.execute.php" class="methodname">mysqli_stmt::execute()</a></span>. All values will be bound as
    strings. Only list arrays are allowed. This new feature is not available
    when MySQLi is compiled with libmysqlclient.
    
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'INSERT INTO users(id, name) VALUES(?,?)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">([</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$username</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
  </div>

  <div class="sect3" id="migration81.new-features.mysqli.mysqli_fetch_column">
   <h4 class="title">New method <span class="methodname"><a href="mysqli-result.fetch-column.php" class="methodname">mysqli_result::fetch_column()</a></span></h4>

   <p class="para">
    <span class="methodname"><a href="mysqli-result.fetch-column.php" class="methodname">mysqli_result::fetch_column()</a></span>
    has been added to allow fetching a single scalar value from the result set.
    The new method accepts an optional 0-based <code class="parameter">column</code>
    parameter of type <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> specifying which column to fetch from.
    
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT username FROM users WHERE id = 123'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetch_column</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
  </div>

 </div>

 <div class="sect2" id="migration81.new-features.pdo_mysql">
  <h3 class="title">PDO</h3>

  <p class="para">
   The <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-local-infile-directory">PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY</a></code></strong> attribute
   has been added, which can be used to specify a directory from which files
   are allowed to be loaded.
   It is only meaningful if <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-local-infile">PDO::MYSQL_ATTR_LOCAL_INFILE</a></code></strong>
   is not enabled, as all directories are allowed in that case.
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.pdo_sqlite">
  <h3 class="title">PDO_SQLite</h3>

  <p class="para">
   SQLite&#039;s <code class="literal">&quot;file:&quot;</code> DSN syntax is now supported,
   which allows specifying additional flags.
   This feature is not available if open_basedir is set.
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">new </span><span style="color: #0000BB">PDO</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlite:file:path/to/sqlite.db?mode=ro'</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.posix">
  <h3 class="title">POSIX</h3>

  <p class="para">
   Added <strong><code><a href="posix.constants.setrlimit.php#constant.posix-rlimit-kqueues">POSIX_RLIMIT_KQUEUES</a></code></strong> and <strong><code><a href="posix.constants.setrlimit.php#constant.posix-rlimit-npts">POSIX_RLIMIT_NPTS</a></code></strong>.
   These rlimits are only available on FreeBSD.
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.standard">
  <h3 class="title">Standard</h3>

  <p class="para">
   <span class="function"><a href="function.fputcsv.php" class="function">fputcsv()</a></span> now accepts a new
   <code class="parameter">eol</code> argument which allows to define a custom
   End of Line sequence, the default remains the same and is <code class="literal">&quot;\n&quot;</code>.
  </p>
 </div>

 <div class="sect2" id="migration81.new-features.spl">
  <h3 class="title">SPL</h3>

  <p class="para">
   <span class="methodname"><a href="splfileobject.fputcsv.php" class="methodname">SplFileObject::fputcsv()</a></span> now accepts a new
   <code class="parameter">eol</code> argument which allows to define a custom
   End of Line sequence, the default remains the same and is <code class="literal">&quot;\n&quot;</code>.
  </p>
 </div>

</div><?php manual_footer($setup); ?>