ID: 43935
User updated by: james dot laver at gmail dot com
Reported By: james dot laver at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: GNU/Linux
PHP Version: 5.2.5
New Comment:
Sorry, i hit submit before I was finished and then I was wrong anyway.
Human error.
<?php
echo "php == true ". (('php'==true)?'true':'false') . "\n";
echo "1 == php " . (('php'==1)?'true':'false');
?>
php == true true
1 == php false
Closing as bogus, sorry about that
Previous Comments:
------------------------------------------------------------------------
[2008-01-25 17:22:50] james dot laver at gmail dot com
That's not the result I get here. Have tried this both with home
compiled PHP and with rPath's binaries
[EMAIL PROTECTED] ~]$ php -v
PHP 5.2.5 (cli) (built: Jan 25 2008 13:02:08)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
------------------------------------------------------------------------
[2008-01-25 16:53:32] php at zjs dot name
In your description, you use "(1 == 'foo')" and "(true == 'foo')"
interchangeably. "(1 == 'foo')" isn't the same as "(true == 'foo')".
Try (using your structure) running:
echo "(true == 'foo') value: " . (true == 'foo') . "<br />";
echo "(1 == 'foo') value: " . (1 == 'foo') . "<br />";
echo "(true === 'foo') value: " . (true === 'foo') . "<br />";
echo "(1 === 'foo') value: " . (1 === 'foo') . "<br />";
Expected result (based on documentation is):
(true == 'foo') value: 1
(1 == 'foo') value:
(true === 'foo') value:
(1 === 'foo') value:
I also created a short test case to ensure that my results matched the
documentation (they did). If you're interested in running it (results
look like http://people.clarkson.edu/~shephezj/temp/comparison_test.php)
it's available at
http://people.clarkson.edu/~shephezj/temp/comparison_test.phps.
(Yes, I know that's a terrible way to code it, but I didn't want to
risk having something interfere with the results).
------------------------------------------------------------------------
[2008-01-25 14:11:06] james dot laver at gmail dot com
Description:
------------
(1 == 'foo') returns boolean true
The documentation claims otherwise (see
http://www.php.net/manual/en/types.comparisons.php)
Logically this cannot be true, and it should not be necessary to use
=== to perform this.
Reproduce code:
---------------
echo "value: " . (true == 'foo');
Expected result:
----------------
"value: 0"
Actual result:
--------------
"value: 1"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43935&edit=1