ID: 40692 User updated by: smlerman at gmail dot com Reported By: smlerman at gmail dot com -Status: Bogus +Status: Open Bug Type: Scripting Engine problem Operating System: Any PHP Version: 5.2.1 New Comment:
Yeah, in 6 years of programming PHP, I never noticed that it isn't a strictly typed language. Trying to use an undefined offset of an array gives an error message. Trying to use a non-existant character index of a string gives an error message. So what is the boolean being converted to such that using an incorrect offset isn't an error? Previous Comments: ------------------------------------------------------------------------ [2007-03-03 15:58:22] [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 PHP is not type strict. ------------------------------------------------------------------------ [2007-03-02 16:20:40] smlerman at gmail dot com Description: ------------ If you try to use a boolean as an array (which most likely means an error occurred somewhere), the value is correctly returned as NULL, but no error message is reported. Obviously not a major problem, but it would make debugging a little easier. Reproduce code: --------------- <?php var_dump(error_reporting()); $a = false; var_dump($a[0]); $b = (string)$a; var_dump($b[0]); ?> Expected result: ---------------- int(8191) [Something like] Notice: Cannot use boolean as array in C:\Documents and Settings\...\boolean_array.php on line 5 NULL Notice: Uninitialized string offset: 0 in C:\Documents and Settings\...\boolean_array.php on line 8 string(0) "" Actual result: -------------- int(8191) NULL Notice: Uninitialized string offset: 0 in C:\Documents and Settings\Scott\My Documents\Test Files\boolean_array.php on line 8 string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40692&edit=1