Edit report at http://bugs.php.net/bug.php?id=52426&edit=1

 ID:                 52426
 Updated by:         [email protected]
 Reported by:        gphemsley at gmail dot com
 Summary:            switch() does not issue PHP Notice for uninitialized
                     variable
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

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

Unless you have "case:" statements inside the switch the condition of
the switch 

never actually gets used, because it does not get used it means no
notices are 

being raised.


Previous Comments:
------------------------------------------------------------------------
[2010-08-18 12:17:41] brendel at krumedia dot de

If you add some cases to the switch the notice it triggered.

------------------------------------------------------------------------
[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

Reply via email to