When indexing a string, the string is cast to an integer:
        (int)'file' == 0

When in a conditional expression, the string is cast to a boolean:
        (bool)'file' == true

It isn't necessarily a fatal error, consider:
        $keys[ '3' ]

- Evan


On Feb 9, 2006, at 4:54 PM, Ian P. Christian wrote:

Can someone explain the following to me?

echo "DEBUG:\n";
var_dump($keys);
var_dump($keys['file']);
var_dump(isset($keys['NOTEXISTING']));
var_dump(isset($keys['file']));
exit;


DEBUG:
string(19) "myConsoleController"
string(1) "m"
bool(true)
bool(true)


Now, it seems that $keys['file'] == $keys[0], which makes sense why the issets
return true. However...
if ('file') echo 'true';
will print moo, therefore 'file' == 1, not 0. Why is this different when using
it as a string offset?
IMO, using a string as a string offset, a fatal error should be raised.

Kind Regards,

--
Ian P. Christian
http://pookey.co.uk

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

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

Reply via email to