Skip to content

is_numeric() limitation #9311

@8ctopus

Description

@8ctopus

Description

is_numeric() is of great help to check if a string contains a number but in some cases, it creates problems:

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 * 10^822890835372110.

In order, to avoid this I would like to suggest the following change to the function:

is_numeric(mixed $value): bool

to

is_numeric(mixed $value, int $flags): bool

$flags being a combination of:

  • NUMERIC_EXPONENT
  • and maybe some other flags...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions