Skip to content

Throw error for invalid characters for number base#22365

Open
Sjord wants to merge 2 commits into
php:masterfrom
Sjord:error-on-invalid-chars
Open

Throw error for invalid characters for number base#22365
Sjord wants to merge 2 commits into
php:masterfrom
Sjord:error-on-invalid-chars

Conversation

@Sjord

@Sjord Sjord commented Jun 19, 2026

Copy link
Copy Markdown

This is about the situation where a character is not within the specified number base. E.g. only 0-9, a-f are allowed for hexadecimal, so what should hexdec('z') do?

In the past, such characters were silently ignored. Since PHP 7.4 a deprecation notice would be generated. This commit changes that to a ValueError.

Earlier RFC:
https://wiki.php.net/rfc/base_convert_improvements

This is about the situation where a character is not within the
specified number base. E.g. only 0-9, a-f are allowed for hexadecimal,
so what should `hexdec('z')` do?

In the past, such characters were silently ignored. Since PHP 7.4 a
deprecation notice would be generated. This commit changes that to a
ValueError.

Earlier RFC:
https://wiki.php.net/rfc/base_convert_improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant