At 16:10 23/05/2010, Davey Shafik wrote:
We also already have a precedent for type-caring functions in the
ctype_* functions:
$ php -r 'var_dump(ctype_digit(123), ctype_digit((string) 123));'
bool(false)
bool(true)
There's a very specific reason for this behavior - ctype treats
numeric values as ASCII and checks if they're in the right
range. So, for instance, ctype_digit(48) would return true. Talk
about a high WTF factor...
Personally I think that's probably a poor decision, and I either way
I wouldn't qualify it as precedent. Sure, there are functions that
don't auto-convert and behave differently depending on the type
that's passed to them - but they're very much the exception to the rule.
Zeev
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php