|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-01 12:14 UTC] oliver dot ridgway at trafford dot ac dot uk
Description:
------------
I can't work out if this a bug or php is working differently than I expected, so i thought I'd report it just in case.
$var1 is not 0 so why is the if statement saying it is?
Reproduce code:
---------------
<?php
class test {
function __construct($var1) {
print($var1 . " ");
if($var1 == 0) {
print('zero');
}
if($var1 != 0) {
print('not');
}
}
}
$test = new test('string');
?>
Expected result:
----------------
string not
Actual result:
--------------
string zero
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 09:00:01 2025 UTC |
# php -r 'var_dump("string" == 0);' bool(true) # php -r 'var_dump("string" != 0);' bool(false) # php -r 'var_dump("string" === 0);' bool(false) # php -r 'var_dump("string" !== 0);' bool(true) RTFM: http://www.php.net/manual/en/language.operators.comparison.php