最近,我开始将 PHP 5.2.x 上的 Drupal 6 模块转换为 PHP 5.3.x 上的 Drupal 7,现在我收到以下警告
Deprecated function: Assigning the return value of new by reference is deprecated in
require_once()
(line 27 of C:\Users\ajinkya\Desktop\xampp\php\PEAR\SOAP\WSDL.php).
WSDL.php 的第 27 行是:require_once 'HTTP/Request.php';
我无法弄清楚此警告的原因。 require_once()
的行为在 PHP 5.3.x 中是否发生了变化?
Drupal 7 中的 file.inc 有一行:require_once DRUPAL_ROOT。 '/includes/stream_wrappers.inc;
并且它不会发出任何警告。为什么?
如果我将 error_reporting(E_ALL & ~E_DEPRECATED);
放在 Drupal 7 的 setting.php 中,警告就会消失。抑制这样的警告好吗?
最佳答案
错误消息表明代码正在使用 $something = &new SomeObject();
而不是 $something = new SomeObject();
。
&new
在古代 PHP 版本中是必需的,以确保对象始终通过引用传递。但在最近的版本中,根本没有理由这样做,因此它已被弃用。
虽然我不知道为什么您的 PHP 会报告不正确的文件名/行号...
关于php - 弃用函数 : require_once(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4770373/