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

No More dir() With Null

When calling dir() with null as parameter, it defaulted to open again the last opened directory. Since PHP 8.1, this is not possible anymore.

PHP code

<?php

$a = dir('/tmp');

$b = dir(null);

var_dump($b);

?>

Before

bool(false)

After

PHP Deprecated:  dir(): Passing null to parameter #1 ($directory) of type string is deprecated

Deprecated: dir(): Passing null to parameter #1 ($directory) of type string is deprecated
bool(false)

PHP version change

This behavior changed in 8.1.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat