Edit report at https://bugs.php.net/bug.php?id=44999&edit=1

 ID:                 44999
 Comment by:         radamanf at gmail dot com
 Reported by:        ethan dot nelson at ltd dot org
 Summary:            0 equals any string
 Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   windows 2003
 PHP Version:        5.2.6
 Block user comment: N
 Private report:     N

 New Comment:

I can see that it's no any logical explanation to keep this BUG unfixed! 
Status: Not a bug -> why??? It's not funny, so many years past.

I do love to use PHP and like that no needed to define variable types, but this 
is generic FAIL.

Come one guys, someone need to fix this, please.

My PHP version
PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:45:59)


Previous Comments:
------------------------------------------------------------------------
[2012-08-24 08:16:07] bugs dot php dot net at simoneast dot net

This is quite ridiculous.  Can this 'feature' of PHP *please* be reconsidered?

------------------------------------------------------------------------
[2008-05-14 22:25:51] ethan dot nelson at ltd dot org

I don't recall PHP ever behaving that way.

So how do you alter a switch statement to use the identical operator instead of 
equivalency?

It seems somewhat odd that any text character would be equvalent to integer 0.  
As I remember the chart it was something like:
0 == '0' true
0 == '' true
0 == null true
0 == false true
0 == 'text' false

Basically if we are going to treat any string as equivalent to 0, the switch 
statement becomes useless when iterating through arrays unless you first strip 
key names of integer 0.

------------------------------------------------------------------------
[2008-05-14 22:20:01] cel...@php.net

see Bug #44990 for explanation

------------------------------------------------------------------------
[2008-05-14 21:51:49] ethan dot nelson at ltd dot org

Description:
------------
Right now, 0 compared to any string will prove true.

Reproduce code:
---------------
<?php

if (0 == 'anystring') echo "True";
else echo "False";

?>

Expected result:
----------------
False

Actual result:
--------------
True


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=44999&edit=1

Reply via email to