Hi Jochem, Leading whitespace is already allowed with PHP's is_numeric() function (and corresponding internal one), math operations, etc. Only when it precedes .123 or -.123 does the behavior change. :-)
Matt ----- Original Message ----- From: "Jochem Maas" Sent: Friday, August 11, 2006 Pierre wrote: >> is_numeric(' .123') // bool(false) > > this one should return true. as Pierre mentions further down changing this behaviour could cause pots of problems for existing code. from an enduser POV having is_numeric(' .123') return true (and therefore having maths operations using ' .123' use that string as if it was '.123' would be tantamount to doing: $v = " .123"; $v = trim($v); var_dump(is_numeric($v), ($v + 0)); In order to be able to move forward and allow for leading spaces in numeric strings maybe an ini setting could be used, one that defaults to false: trim_numeric_strings_before_usage = 0; such a setting if true would essentially trim space (like the trim() function does) form strings before they were checked (by is_numeric) and before being used in calculations. in php6 the default of this ini setting could be changed to true (which would offer quite some time to check for possible unforeseen problems and eventually in php7,8,9 the setting could dissappear entirely once the community is satisfied any/all problems have been dissipated. I have no idea if this is feasable or desirable (I'm aware of the animosity towards new ini settings!) but it might offer a potential resolution between moving forward and protecting muppets like myself from 'strange behaviour' related to autocasting of numeric strings. rgds, Joche, -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php