note 73922 rejected from language.operators.comparison by bobby
| From: | bobby@php.net | Date: | Fri, 16 Mar 2007 15:05:51 +0000 |
| Subject: | note 73922 rejected from language.operators.comparison by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124520@lists.php.net to get a copy of this message | ||
Note Submitter: php_dev at dunnbypaul dot net
----
Here's a PHP peculiarity:
<?
echo ( 0==true ? "true" : "false") . "\n";
echo ( 1==true ? "true" : "false") . "\n";
echo ( 596==true ? "true" : "false") . "\n";
?>
produces:
false
true
true
no surprises, so far, and...
<?
echo ( 0=="true" ? "true" : "false") . "\n";
echo ( 1=="true" ? "true" : "false") . "\n";
echo ( 596=="true" ? "true" : "false") . "\n";
?>
produces:
true
false
false
still okay, but this...
<?
echo ( true=="true" ? "true" : "false") . "\n";
?>
produces:
true !?
what's up?
it's kind of like...
<?
echo ( sally=="sally" ? "true" : "false") . "\n";
?>
which produces:
true
but it should be more like..
<?
define("sally",1);
echo ( sally=="sally" ? "true" : "false") . "\n";
?>
which produces:
false
Can anybody explain this peculiar behaviour?