dl() Rejects NUL Bytes In The Extension Filename

dl() used to accept an extension filename containing a NUL byte and only reported the standard warning once enable_dl turned out to be off. In PHP 8.6, a NUL byte in the argument throws a ValueError before that check is even reached.

PHP code

<?php

try {
    var_dump(dl("foo\0bar"));
} catch (\ValueError $e) {
    echo $e->getMessage(), "\n";
}

?>

Before

PHP Warning:  dl(): Dynamically loaded extensions aren't enabled in /codes/dlNullByteValueError.php on line 4

Warning: dl(): Dynamically loaded extensions aren't enabled in /codes/dlNullByteValueError.php on line 4
bool(false)

After

dl(): Argument #1 ($extension_filename) must not contain any null bytes

PHP version change

This behavior changed in 8.6

See Also

Error Messages