|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-12 03:21 UTC] sniper@php.net
[2001-06-12 03:21 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 04:00:02 2025 UTC |
If there is a conditional on a non-existant (not-set) variable, it returns an automatic true, instead of an automatic false. Examples: (assume that $myVar has never been set) 1. if ($myVar) echo "hello!"; <-- this does echo 'hello' 2. if ($myVar == "42") echo "babel"; <-- this echoes 'babel' 3. switch ($myVar) { case "42": echo "babel"; default: echo "fish"; } the above example echoes "babel" (!!). I am aware that I should actually check for isset ($myVar), but these examples are all from legacy code that I looked at and that have suddenly started to produce the opposite result as desired. What I have described is still a bug, since a non existant variable should never return true when compared to a scalar. Thanks for your help, Ronen. PS: This seems to have appeared with PHP4.04pl1. Also, I can send you our php.ini file, if needed.