Re: [RFC] Throw ValueError for invalid characters in number base functions
| From: | Sjoerd Langkemper | Date: | Thu, 24 Sep 2026 12:29:40 +0000 |
| Subject: | Re: [RFC] Throw ValueError for invalid characters in number base functions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132623@lists.php.net to get a copy of this message | ||
On Thu, Sep 3, 2026, at 13:41, Morgan wrote:
> Just incidentally, does this list of functions include intval()?
On Thu, Sep 24, 2026, at 14:09, Morgan wrote:
> Will, for example, intval('hello world', 20) throw?
It does not. The reason is technical: intval is implemented differently than base_convert and *dec.
intval uses libc strtol, whereas the other function do the parsing themselves. It should probably be
more strict and also throw an exception, but that is not part of this RFC.
I thought it was pretty clear that intval was not affected. Both the RFC and the top email of this
thread give a list of affected functions, which does not include intval:
> This will throw an error for octdec, hexdec, bindec and base_convert on invalid input.
The RFC also says explicitly that intval is not affected:
> Other string-to-number or decoding functions (such as
base64_decode()èݾ¦’
> .ôT÷JŠú, intval(), etc.) are currently unaffected by this change.
Regards,
Sjoerd Langkemper