From: tschoonen at gmail dot com Operating system: Ubuntu 13.04x64 PHP version: 5.4.17 Package: *General Issues Bug Type: Bug Bug description:PHP generates no error when calling a NULL variable as array
Description: ------------ --- >From manual page: http://www.php.net/language.types.array --- I accidentally discovered that when you try to call a NULL variable as an array, PHP will simply return NULL without triggering any form of error. I don't believe that this is intended behaviour, as calling an undefined offset in an array causes a warning. My sincere apologies if this bug has been reported earlier, I spent quite a while searching in and outside of php.net to no avail. Test script: --------------- <?php error_reporting(-1); $array = array(); // This will return NULL and trigger an 'undefined offset' notice. var_dump($array[1]); // This will return NULL and trigger an 'undefined variable' notice. var_dump($undefined[3]); var_dump($undefined[1]); $null_var = null; // This, however, will return NULL and give no error. var_dump($null_var[1]); Expected result: ---------------- PHP Notice: Undefined offset: 1 in /var/www/null.php on line 8 NULL PHP Notice: Undefined variable: undefined in /var/www/null.php on line 11 NULL PHP Notice: Undefined variable: undefined in /var/www/null.php on line 12 NULL NULL -- Edit bug report at https://bugs.php.net/bug.php?id=65310&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65310&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65310&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65310&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65310&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65310&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65310&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65310&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65310&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65310&r=support Expected behavior: https://bugs.php.net/fix.php?id=65310&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65310&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65310&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65310&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65310&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65310&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65310&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65310&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65310&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65310&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65310&r=mysqlcfg