Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.

See Also

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat