<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/migration72.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'migration72.deprecated.php',
    1 => 'PHP 7.2.x 中废弃的功能',
    2 => 'PHP 7.2.x 中废弃的功能',
  ),
  'up' => 
  array (
    0 => 'migration72.php',
    1 => '从 PHP 7.1.x 移植到 PHP 7.2.x',
  ),
  'prev' => 
  array (
    0 => 'migration72.incompatible.php',
    1 => '不向下兼容的变更',
  ),
  'next' => 
  array (
    0 => 'migration72.other-changes.php',
    1 => '其他变更',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'appendices/migration72/deprecated.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="migration72.deprecated" class="sect1">
 <h2 class="title">PHP 7.2.x 中废弃的功能</h2>

 <div class="sect2" id="migration72.deprecated.unquoted-strings">
  <h3 class="title">不带引号的字符串</h3>

  <p class="para">
   不带引号的字符串是不存在的全局常量，转化成他们自身的字符串。
   在以前，该行为会产生
   <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong>，但现在会产生
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>。在下一个 PHP 主版本中，将抛出
   <span class="classname"><a href="class.error.php" class="classname">Error</a></span> 异常。
  </p>

  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">NONEXISTENT</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Output:<br />Warning: Use of undefined constant NONEXISTENT - assumed 'NONEXISTENT' (this will throw an Error in a future version of PHP) in %s on line %d<br />string(11) "NONEXISTENT"<br />*/</span></span></code></div>
   </div>

  </div>
 </div>

 <div class="sect2" id="migration72.deprecated.png2wbmp-jpeg2wbmp">
  <h3 class="title"><span class="function"><a href="function.png2wbmp.php" class="function">png2wbmp()</a></span> 和 <span class="function"><a href="function.jpeg2wbmp.php" class="function">jpeg2wbmp()</a></span></h3>

  <p class="para">
   GD 扩展内的 <span class="function"><a href="function.png2wbmp.php" class="function">png2wbmp()</a></span> 和 <span class="function"><a href="function.jpeg2wbmp.php" class="function">jpeg2wbmp()</a></span> 现已被废弃，将在下一个 PHP 主版本中移除。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.INTL_IDNA_VARIANT_2003-variant">
  <h3 class="title"><strong><code><a href="intl.constants.php#constant.intl-idna-variant-2003">INTL_IDNA_VARIANT_2003</a></code></strong> 转化</h3>

  <p class="para">
   Intl 扩展废弃了
   <strong><code><a href="intl.constants.php#constant.intl-idna-variant-2003">INTL_IDNA_VARIANT_2003</a></code></strong> 转化，为<span class="function"><a href="function.idn-to-ascii.php" class="function">idn_to_ascii()</a></span> 和
   <span class="function"><a href="function.idn-to-utf8.php" class="function">idn_to_utf8()</a></span> 的默认选项。
   PHP 7.4 会把默认值设置为
   <strong><code><a href="intl.constants.php#constant.intl-idna-variant-uts46">INTL_IDNA_VARIANT_UTS46</a></code></strong>，
   并在下一个 PHP 主版本中完全移除 <strong><code><a href="intl.constants.php#constant.intl-idna-variant-2003">INTL_IDNA_VARIANT_2003</a></code></strong>。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.__autoload-method">
  <h3 class="title"><span class="function"><a href="function.autoload.php" class="function">__autoload()</a></span> 方法</h3>

  <p class="para">
   <span class="function"><a href="function.autoload.php" class="function">__autoload()</a></span> 方法已被废弃，
   因为和  <span class="function"><a href="function.spl-autoload-register.php" class="function">spl_autoload_register()</a></span> 相比功能较差 (因为无法链式处理多个  autoloader)，
   而且也无法在两种 autoloading 样式中配合使用。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.track_errors-and-php_errormsg">
  <h3 class="title"><code class="parameter">track_errors</code> ini 设置和 <code class="literal">$php_errormsg</code> 变量</h3>

  <p class="para">
   当开启了 <code class="parameter">track_errors</code> ini 设置，出现非致命错误时，
   会在本地作用域创建 <code class="literal">$php_errormsg</code> 变量。
   由于提供了更好的方式： <span class="function"><a href="function.error-get-last.php" class="function">error_get_last()</a></span> 来获取此类错误信息，该功能被废弃。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.create_function-function">
  <h3 class="title"><span class="function"><a href="function.create-function.php" class="function">create_function()</a></span> 函数</h3>

  <p class="para">
   考虑到此函数的安全隐患问题（它是 <span class="function"><a href="function.eval.php" class="function">eval()</a></span> 的瘦包装器），该过时的函数现在已被废弃。
   更好的选择是<a href="functions.anonymous.php" class="link">匿名函数</a>。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.mbstringfunc_overload-ini-setting">
  <h3 class="title"><code class="parameter">mbstring.func_overload</code> ini 设置</h3>

  <p class="para">
   由于此设置会影响环境中的字符串系列函数，带来相互操作中的问题，它现在已被废弃。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.unset-cast">
  <h3 class="title"><code class="literal">(unset)</code> 类型强制转化</h3>

  <p class="para">
   转化任意表达式为此类型，结果总是 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，所以这个多余的类型转化现在也就被废弃了。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.parse_str-no-second-arg">
  <h3 class="title"><span class="function"><a href="function.parse-str.php" class="function">parse_str()</a></span> 不加第二个参数</h3>

  <p class="para">
   使用 <span class="function"><a href="function.parse-str.php" class="function">parse_str()</a></span> 时，不加第二个参数会导致查询字符串参数导入当前符号表。
   考虑到安全隐患问题，不加第二个参数使用
   <span class="function"><a href="function.parse-str.php" class="function">parse_str()</a></span> 的行为已被废弃。
   此函数的第二个选项为必填项，它使查询字符串转为 Array。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.gmp_random-function">
  <h3 class="title"><span class="function"><a href="function.gmp-random.php" class="function">gmp_random()</a></span> 函数</h3>

  <p class="para">
   此函数基于未知的、取决于平台的 limb 尺寸产生随机数。因此，该函数已被废弃。
   使用更好的方式产生随机数： GMP 扩展中的
   <span class="function"><a href="function.gmp-random-bits.php" class="function">gmp_random_bits()</a></span> 和
   <span class="function"><a href="function.gmp-random-range.php" class="function">gmp_random_range()</a></span>。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.each-function">
  <h3 class="title"><span class="function"><a href="function.each.php" class="function">each()</a></span> 函数</h3>

  <p class="para">
   使用此函数遍历时，比普通的 <code class="literal">foreach</code> 更慢，
   并且给新语法的变化带来实现问题。因此它被废弃了。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.assert-string-arg">
  <h3 class="title"><span class="function"><a href="function.assert.php" class="function">assert()</a></span> 一个字符串参数</h3>

  <p class="para">
   <span class="function"><a href="function.assert.php" class="function">assert()</a></span> 字符串参数将要求它能被 <span class="function"><a href="function.eval.php" class="function">eval()</a></span> 执行。
   考虑到可能被执行远程代码，废弃了字符串的 <span class="function"><a href="function.assert.php" class="function">assert()</a></span>，最好提供 bool 的表达式。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.errcontext-arg-of-error-handlers">
  <h3 class="title">错误处理器内的 <code class="literal">$errcontext</code> 参数</h3>

  <p class="para">
   <code class="literal">$errcontext</code> 参数包含了错误网站的所有本地变量。
   考虑到它很少被用到，而且还会导致内部优化问题，它现在被废弃了。
   代替用法：调试器应该自己取回错误站点的本地变量。
  </p>
 </div>

 <div class="sect2" id="migration72.deprecated.read_exif_data-function">
  <h3 class="title"><span class="function"><a href="function.read-exif-data.php" class="function">read_exif_data()</a></span> 函数</h3>

  <p class="para">
   <span class="function"><a href="function.read-exif-data.php" class="function">read_exif_data()</a></span> 别名已被废弃
   使用 <span class="function"><a href="function.exif-read-data.php" class="function">exif_read_data()</a></span> 函数代替。
  </p>
 </div>

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