note 100297 deleted from function.is-string by danbrown

From: Date: Wed, 06 Oct 2010 16:23:28 +0000
Subject: note 100297 deleted from function.is-string by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173026@lists.php.net to get a copy of this message
Note Submitter: derek dot p dot moore at gmail dot com ---- son9ne's note below isn't entirely accurate, consider the following code: $test = ''; function func($var) { return $var; } function func2($var) { switch ($var) { case is_string($var): return $var; case is_array($var): return $var; } } function func3($var) { switch ($var) { case is_string($var): print "string!"; break; case is_array($var): print "array!"; break; } } if (is_array($test)): print "array!"; elseif (is_string($test)): print "string!"; endif; if (is_array(func($test))): print "array!"; elseif (is_string(func($test))): print "string!"; endif; if (is_array(func2($test))): print "array!"; elseif (is_string(func2($test))): print "string!"; endif; func3($test); It will output: string! string! string! array! I would expect the output: string! string! string! string! I think this is a bug in PHP's switch statement.

« previous php.notes (#173026) next »