Bug #52426 [NEW]: switch() does not issue PHP Notice for uninitialized variable

From: Date: Sat, 24 Jul 2010 06:21:08 +0000
Subject: Bug #52426 [NEW]: switch() does not issue PHP Notice for uninitialized variable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152709@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.2.14 Package: Scripting Engine problem Bug Type: Bug Bug description:switch() does not issue PHP Notice for uninitialized variable Description: ------------ If the parameter passed to switch() is an uninitialized variable, a PHP Notice documenting such is not issued. Test script: --------------- <?php error_reporting( E_ALL ); var_dump( PHP_VERSION, $mode ); switch( $mode ) { default: print '<p>There should be 2 notices of "undefined variable: mode".<br />' . "\n"; print 'One for the var_dump() and one for the switch().</p>' . "\n"; break; } highlight_file( $_SERVER['SCRIPT_FILENAME'] ); ?> Expected result: ---------------- In the above script, two notices of "Undefined variable: mode" should be issued, one for the var_dump() and one for the switch(). Actual result: -------------- In reality, only one notice is issued: the one for the var_dump(). (Taking out that call means that no notices are issued.) I've gotten confirmation that this is present in 5.2.4, 5.2.5, and 5.3.2. -- Edit bug report at http://bugs.php.net/bug.php?id=52426&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52426&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52426&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52426&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52426&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52426&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52426&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52426&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52426&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52426&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52426&r=support Expected behavior: http://bugs.php.net/fix.php?id=52426&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52426&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52426&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52426&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52426&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52426&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52426&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52426&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52426&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52426&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52426&r=mysqlcfg

« previous php.bugs (#152709) next »