Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
rfc:trailing_whitespace_numerics [2019/03/05 23:58] – new 1.0, Under Discussion ajf | rfc:trailing_whitespace_numerics [2019/03/06 06:13] – Typo bwoebi |
---|
| |
* <php>is_numeric()</php> returns <php>TRUE</php> only for numeric strings | * <php>is_numeric()</php> returns <php>TRUE</php> only for numeric strings |
* Arithmetic operations (e.g. <php>$a * $b</php>, </php>$a + $b</php>) accept and implicitly convert both numeric and leading-numeric strings, but trigger the <php>E_NOTICE</php> “A non well formed numeric value encountered” for leading-numeric strings | * Arithmetic operations (e.g. <php>$a * $b</php>, <php>$a + $b</php>) accept and implicitly convert both numeric and leading-numeric strings, but trigger the <php>E_NOTICE</php> “A non well formed numeric value encountered” for leading-numeric strings |
* When ''strict_types=1'' is not set, <php>int</php> and <php>float</php> parameter and return type declarations will accept and implicitly convert both numeric and leading-numeric strings, but likewise trigger the same <php>E_NOTICE</php> | * When ''strict_types=1'' is not set, <php>int</php> and <php>float</php> parameter and return type declarations will accept and implicitly convert both numeric and leading-numeric strings, but likewise trigger the same <php>E_NOTICE</php> |
* Type casts and other explicit conversions to integer or float (e.g. <php>(int)</php>, <php>(float)</php>, <php>settype()</php>) accept all strings, converting both numeric and leading-numeric strings and producing 0 for non-numeric strings | * Type casts and other explicit conversions to integer or float (e.g. <php>(int)</php>, <php>(float)</php>, <php>settype()</php>) accept all strings, converting both numeric and leading-numeric strings and producing 0 for non-numeric strings |
| |
===== Future Scope ===== | ===== Future Scope ===== |
If adopted, this would make Nikita Popov's [[rfc:string_to_number_comparison|//PHP RFC: Saner string to number comparisons//]] look more reasonable. | If adopted, this would make Nikita Popov's [[rfc:string_to_number_comparison|PHP RFC: Saner string to number comparisons]] look more reasonable. |
| |
I would also plan a second RFC in a similar vain to Nikita's, which would simplify things by removing the concept of leading-numeric strings: strings are either numeric and accepted, or non-numeric and not accepted. | I would also plan a second RFC in a similar vein to Nikita's, which would simplify things by removing the concept of leading-numeric strings: strings are either numeric and accepted, or non-numeric and not accepted. |
| |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |