Bug #53584 [Opn->Bgs]: Asterisk character equals 0

From: Date: Mon, 20 Dec 2010 21:20:42 +0000
Subject: Bug #53584 [Opn->Bgs]: Asterisk character equals 0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157156@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53584&edit=1 ID: 53584 Updated by: cataphract@php.net Reported by: andy dot mezey at gmail dot com Summary: Asterisk character equals 0 -Status: Open +Status: Bogus Type: Bug -Package: Output Control +Package: Scripting Engine problem Operating System: Linux PHP Version: 5.3.4 Block user comment: N Private report: N New Comment: 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) Previous Comments: ------------------------------------------------------------------------ [2010-12-20 21:45:11] 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; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53584&edit=1

« previous php.bugs (#157156) next »