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

From: Date: Wed, 18 Aug 2010 10:17:41 +0000
Subject: Bug #52426 [Com]: switch() does not issue PHP Notice for uninitialized variable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153552@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52426&edit=1 ID: 52426 Comment by: brendel at krumedia dot de Reported by: gphemsley at gmail dot com Summary: switch() does not issue PHP Notice for uninitialized variable Status: Open Type: Bug Package: Scripting Engine problem PHP Version: 5.2.14 Block user comment: N New Comment: If you add some cases to the switch the notice it triggered. Previous Comments: ------------------------------------------------------------------------ [2010-07-24 08:21:08] gphemsley at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=52426&edit=1

« previous php.bugs (#153552) next »