I’m encountering a consistency issue with an E_DEPRECATED message.
I have the following snippet of code that can be run on the command-line to demonstrate.
php -d error_reporting=-1 -d display_errors=1 -r 'function foo(&$bar) {return $bar->title . ".";} $bar = new stdClass(); $bar->title = "foobar"; print foo(&$bar) . PHP_EOL . PHP_VERSION . PHP_EOL;'
Readable version:
// error reporting set to E_ALL via command-line
function foo(&$bar) {
return $bar->title . ".";
}
$bar = new stdClass();
$bar->title = "foobar";
print foo(&$bar) . PHP_EOL . PHP_VERSION . PHP_EOL;
// ^ this should raise E_DEPRECATED
I’m trying to trigger a PHP Deprecated: Call-time pass-by-reference has been deprecated message with this snippet foo(&$bar) but for some reason it’s not being raised on my local install.
I’ve passed it around to several other environments running various versions of php, different os’s etc. and gotten different results:
EXPECTED:
mike@server:~$ php -d error_reporting=-1 -d display_errors=1 -r 'function foo(&$bar) {return $bar->title . ".";} $bar = new stdClass(); $bar->title = "foobar"; print foo(&$bar) . PHP_EOL . PHP_VERSION . PHP_EOL;'
PHP Deprecated: Call-time pass-by-reference has been deprecated in Command line code on line 1
foobar.
5.3.5-1ubuntu7.2
IN MY ENVIRONMENT:
mike@local:~$ php -d error_reporting=-1 -d display_errors=1 -r 'function foo(&$bar) {return $bar->title . ".";} $bar = new stdClass(); $bar->title = "foobar"; print foo(&$bar) . PHP_EOL . PHP_VERSION . PHP_EOL;'
foobar.
5.3.5-1ubuntu7.2
What could be causing this?
Update:
I did the following to verify that deprecated errors are still being thrown in my environment:
mike@local:~$ php -d error_reporting=-1 -d display_errors=1 -r 'eregi("test", "test");'
Deprecated: Function eregi() is deprecated in Command line code on line 1
By any chance, is your
allow_call_time_pass_referencesetting enabled in php.ini?Especially note: