Base Conversion Reports Invalid Characters¶
The base conversion functions, such as octdec(), base_convert(), binhex() or hexdex() used to ignore silently invalid characters. Invalid characters are the characters that do no belong to the base: for example, 2 or 3 in binary, or a in decimal, or g in hexadecimal.
The characters are still ignored, but they now raise a warning.
PHP code¶
<?php
print octdec('789');
print base_convert('123', 2, 10);
print bindec('a10');
print hexdec('defg');
?>
Before¶
7123567
After¶
PHP Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 3
Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 3
7PHP Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 4
Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 4
1PHP Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 5
Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 5
2PHP Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 6
Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /codes/InvalidBaseCharacter.php on line 6
3567
PHP version change¶
This behavior changed in 7.4