#31458 [Bgs->Csd]: 0 == '%' is true?

From: Date: Sun, 09 Jan 2005 21:00:38 +0000
Subject: #31458 [Bgs->Csd]: 0 == '%' is true?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71654@lists.php.net to get a copy of this message
ID: 31458 User updated by: falk at brockerhoff dot org Reported By: falk at brockerhoff dot org -Status: Bogus +Status: Closed Bug Type: Unknown/Other Function Operating System: FreeBSD 5.3 PHP Version: 4.3.10 New Comment: Oh, it's not a bug, it's a feature: http://www.php.net/manual/en/language.operators.comparison.php Previous Comments: ------------------------------------------------------------------------ [2005-01-09 21:58:39] tony2001@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Use === to compare variables of different types and read the documentation about type juggling. ------------------------------------------------------------------------ [2005-01-09 21:51:53] falk at brockerhoff dot org Description: ------------ I got a strange problem while comparing a numeric while with the string "%". Using the numeric value 0 and the string "%" in an if-statement results with true!? Reproduce code: --------------- $foo = '%'; $bar = 0; if ($foo == $var) { echo "what the hell is going on?!\n"; } $foo = '%'; $bar = '0'; if ($foo == $var) { echo "what the hell is going on?!\n"; } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31458&edit=1

« previous php.bugs (#71654) next »