ID: 39018 User updated by: mpb dot mail at gmail dot com Reported By: mpb dot mail at gmail dot com -Status: Bogus +Status: Open Bug Type: Scripting Engine problem Operating System: Gentoo Linux PHP Version: 5.1.6 New Comment:
While operator precedence explains the notice generated by line 7 of my original example, it does not explain the other lines. Here is a simpler example clearly showing this bug has nothing to do with operator precedence. The notices in line 11 and 14 should be suppressed - but they are not. Compare lines 11 and 14 to lines 12 and 15 respectively. Reproduce code: --------------- <?php error_reporting (E_ALL | E_NOTICE); $s = 'test'; $a = array ('t', 'e', 's', 't'); if ( $s[4] ); // line 8, not suppressed if ( $a[4] ); // line 9, not suppressed if ( @ $s[4] ); // line 11, not suppressed if ( @ $a[4] ); // line 12, suppressed if ( @ ( $s[4] ) ); // line 14, not suppressed if ( @ ( $a[4] ) ); // line 15, suppressed if ( @ ( $x=$s[4] ) ); // line 17, suppressed if ( @ ( $y=$a[4] ) ); // line 18, suppressed print "Done!\n"; ?> Expected result: ---------------- Notice: Uninitialized string offset: 4 in /borg/ripple/parke/test4.php on line 8 Notice: Undefined offset: 4 in /borg/ripple/parke/test4.php on line 9 Done! Actual result: -------------- Notice: Uninitialized string offset: 4 in /borg/ripple/parke/test4.php on line 8 Notice: Undefined offset: 4 in /borg/ripple/parke/test4.php on line 9 Notice: Uninitialized string offset: 4 in /borg/ripple/parke/test4.php on line 11 Notice: Uninitialized string offset: 4 in /borg/ripple/parke/test4.php on line 14 Done! Previous Comments: ------------------------------------------------------------------------ [2006-10-03 19:57:35] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Operator precedence is working against you in this instance. The operation involving offset operation is before before the error blocking operator is considered. ------------------------------------------------------------------------ [2006-10-02 19:28:34] mpb dot mail at gmail dot com Description: ------------ The error control operator '@' fails to suppress (some) "Uninitialized string offset" notices. See example for details. The problem also occurs on with PHP 4.4.x. Reproduce code: --------------- <?php error_reporting (E_ALL | E_NOTICE); $x = 'test'; $x[4]; // No notice at all - compiler optimization?? @$y = $x[4]; // Notice supressed. @'a' == $x[4]; // Notice NOT supressed - but it should be. @$x[4] == 'a'; // Notice NOT supressed - but it should be. (@$x[4]) == 'a'; // Notice NOT supressed - but it should be. (@($x[4])) == 'a'; // Notice NOT supressed - but it should be. @($x[4]) == 'a'; // Notice NOT supressed - but it should be. @($x[4] == 'a'); // Notice supressed. print "Done!\n"; ?> Expected result: ---------------- Done! Actual result: -------------- Notice: Uninitialized string offset: 4 in /home/build/test.php on line 7 Notice: Uninitialized string offset: 4 in /home/build/test.php on line 8 Notice: Uninitialized string offset: 4 in /home/build/test.php on line 9 Notice: Uninitialized string offset: 4 in /home/build/test.php on line 10 Notice: Uninitialized string offset: 4 in /home/build/test.php on line 11 Done! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39018&edit=1