From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      4.2.3
PHP Bug Type:     Documentation problem
Bug description:  'foo'==0 cast on comparison

yesterday i submitted an 'foo'==0 bug (id=20708) in the Scripting Engine
problem Category, well i understand that was stupid and my bug went bogus
just as ahundret other submitted 'foo'==0 bugs i later found in the
database.

but i think it is an issue.

the manual states:

Example: $a == $b 
Name: Equal 
Result: TRUE if $a is equal to $b
 
this is not specific enough for a language where 'foo'==0 evaluates TRUE.

when i write 'foo'==0 i do *not* want to know if they are same type

i want to know one of those:
'foo'==(string)0 *or* (int)'foo'==0

obviously, only one of those can happen. if you want the other thing to
happen, you must cast explicitly. the manual doesn't state which one
happens implicitly.

automatic type casting is great for coding, but one can't just let it
happen, one must know exactly what it does. 

i hope you understand that a nonempty string to be the same as a zero
integer messes with the brain of any php newbie used to fixed type
languages if you don't explain to him why.

the manual shouldn´t just state that 'foo' equals to 0, because for this
to happen php seems to use a cast precedence for comparison operations -
whatever it is, the manual should explain it.

PS:
if you bogus me again i wont insist.

-- 
Edit bug report at http://bugs.php.net/?id=20726&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20726&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20726&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20726&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20726&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20726&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20726&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20726&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20726&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20726&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20726&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20726&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20726&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20726&r=isapi


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to