[php-src] Issue #9311: is_numeric() limitation
| From: | 8ctopus | Date: | Fri, 12 Aug 2022 10:37:59 +0000 |
| Subject: | [php-src] Issue #9311: is_numeric() limitation | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242196@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9311
Author: 8ctopus
### Description
is_numeric() is of great help to check if a string contains a number but in some cases,
it creates problems:
```php
is_numeric('2E822890835372110'); // true
is_numeric('64091761E47298917'); // true
```
If I understand correctly, is_numeric detects the E within the string and considers it
as exponent, so in the first case 2^822890835372110.
In order, to avoid this I would like to suggest the following change to the function:
```php
is_numeric(mixed $value): bool
```
to
```php
is_numeric(mixed $value, int $flags): bool
```
$flags being a combination of:
- NUMERIC_EXPONENT
- and maybe some other flags...