|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-12-20 21:45 UTC] andy dot mezey at gmail dot com
Description: ------------ Using PHP Version 5.3.2-1ubuntu4.5. When a variable holds the value "*" and when being compared against the values 0 or "0" using the equal operator, true is always returned. I did look here: http://php.net/manual/en/language.types.type-juggling.php and I do not see a reason for this behavior. The Identical operator does however return false which is what you would expect. Test script: --------------- $var1 = "*"; if( $var1 == 0 ) { echo "ok"; } switch( $var1 ) { case 0 : echo "ok"; break; } $var2 = "\*"; if( $var2 == 0 ) { echo "ok"; } switch( $var2 ) { case 0 : echo "ok"; break; } Expected result: ---------------- Should return false. Actual result: -------------- Returns true; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 10:00:01 2025 UTC |
Everything in your test script is expected behavior. "*" == "0" being true is not, but that claim isn't tested in the test script and I can't reproduce, which leads me to conclude it was a mistake on the your part. php -r 'var_dump("*" == "0");' bool(false)