#50613 [NEW]: Expected warnings/notices not outputed by PHP on simple array access.
From: felix at amerimerchant dot com
Operating system: Linux
PHP version: 5.3.1
PHP Bug Type: Scripting Engine problem
Bug description: Expected warnings/notices not outputed by PHP on simple array access.
Description:
------------
When accessing a variable containing a boolean, integer, floating point,
or null value using square bracket syntax, no warning or notice is
generated (even if the array index could not exist if the type was silently
juggled into a string or array). This occurs even with E_STRICT turned on.
Reproduce code:
---------------
<?php
error_reporting( -1 );
$x = "string";
print( $x[9] );
$x = array(1, 2, 3);
print( $x[9] );
$x = false;
print( $x[9] );
$x = 3;
print( $x[9] );
$x = 3.01;
print( $x[9] );
$x = null;
print( $x[9] );
$x = new StdClass();
print( $x[9] );
?>
Expected result:
----------------
PHP Notice: Uninitialized string offset: 9 in /tmp/test.php on line 6
PHP Notice: Undefined offset: 9 in /tmp/test.php on line 9
[A notice or warning for line 12]
[A notice or warning for line 15]
[A notice or warning for line 18]
[A notice or warning for line 21]
PHP Fatal error: Cannot use object of type stdClass as array in
/tmp/test.php on line 24
Actual result:
--------------
PHP Notice: Uninitialized string offset: 9 in /tmp/test.php on line 6
PHP Notice: Undefined offset: 9 in /tmp/test.php on line 9
PHP Fatal error: Cannot use object of type stdClass as array in
/tmp/test.php on line 24
--
Edit bug report at http://bugs.php.net/?id=50613&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50613&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50613&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50613&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50613&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50613&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50613&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50613&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50613&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50613&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50613&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50613&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50613&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50613&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50613&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50613&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50613&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50613&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50613&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50613&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50613&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50613&r=mysqlcfg
Thread (9 messages)
- felix at amerimerchant dot com