On 4/19/05, Sara Golemon <[EMAIL PROTECTED]> wrote:
> > Just came across this:
> > http://bugs.php.net/bug.php?id=23110
> >
> > I've been programming PHP since PHP 3
> > and wasn't even aware of this behavior.
> >
> And now you are.
> 
> PHP is a loosely typed language.  Odds are it's one of the things which
> attracted you to it in the first place.

I can understand 0 == '' is true, but the string thingy is a bit surprising me.

I thought === is only used when comparing different types, so it's
used to strictly compare things of the same type as well? (as the
case, strings, but objects come to mind as well)

I guess === is a strict equality operator more than it is a type
equality operator.

> > "Numeric strings"? What is that?
> >
> Roughly speaking, a string matching the pattern:
> /^(-\d)?\d*(.[0-9]*)?(E[+-]\d+)?/
> Though that's not precisely how the engine handles it internally.
> 
> > if ($typedPassword == $password) doSomeAdministrativeTaskHere();
> >
> > You better not use '000000001' as password, or '0e00.0000', since
> > people would be able to use '' (yes, empty string!) to hack your app.
> >
> Quick! Go change your password!

<?php echo '0' == '0.0000e0' ?>
1

<?php echo '0' == 'asadoaskd' ?>
(nothing, false)

<?php echo '0' == (int)'adasd' ?>
1

That confuses me more (but understandable, and thank God PHP behave
this way)... I thought 'asdasd' is 0 when [implicitly] converted to
int [for comparison]? I guess I never knew PHP well :-(

-- 
Hendy Irawan
http://www.gauldong.net
http://dev.gauldong.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to