Edit report at http://bugs.php.net/bug.php?id=53584&edit=1
ID: 53584 Comment by: andy dot mezey at gmail dot com Reported by: andy dot mezey at gmail dot com Summary: Asterisk character equals 0 Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 5.3.4 Block user comment: N Private report: N New Comment: Yes, I see it now. (http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion). I'm very sorry to have wasted each of your time. Previous Comments: ------------------------------------------------------------------------ [2010-12-20 22:36:09] ras...@php.net "*" == 0 and "*" == "0" are very different cases. In the first you are comparing a string to an integer, so the string will be cast to an integer and the integer value of "*" is 0 so that will be equal. In the second you are comparing strings, so "*" and "0" will not be equal. ------------------------------------------------------------------------ [2010-12-20 22:30:26] andy dot mezey at gmail dot com Are you saying when running the examples provided nothing was printed to the screen; that the statements returned false? I just tried my examples on another server running PHP Version 5.2.13 and received the same results as before. When I execute the code var_dump( "*" == 0 );, bool(true) is returned. ------------------------------------------------------------------------ [2010-12-20 22:20:42] cataphr...@php.net 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) ------------------------------------------------------------------------ [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