parse_str() Rejects NUL Bytes In The Query String¶
parse_str() used to accept a query string containing a NUL byte and silently parsed only the part before it. In PHP 8.6, a NUL byte in the $string argument throws a ValueError.
PHP code¶
<?php
try {
parse_str("foo\0bar=1", $result);
var_dump($result);
} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
Before¶
array(1) {
[foo]=>
string(0)
}
After¶
parse_str(): Argument #1 ($string) must not contain any null bytes
PHP version change¶
This behavior changed in 8.6