getenv() Rejects NUL Bytes In The Variable Name¶
getenv() used to accept a variable name containing a NUL byte, and simply returned false since no such variable can exist. In PHP 8.6, a NUL byte in the name argument throws a ValueError.
PHP code¶
<?php
var_dump(getenv("FOO\0BAR"));
?>
Before¶
bool(false)
After¶
getenv(): Argument #1 ($name) must not contain any null bytes
PHP version change¶
This behavior changed in 8.6