Filename cannot be empty¶
Description¶
fopen()’s first argument is of type string, though the empty string is not allowed, as it does not lead to any file.
This check prevents using an empty string, or its equivalent as null or false, to access a file.
This error also applies to file_get_contents and file_put_contents(). It doesn’t apply to unlink and rmdir.
Example¶
<?php
fopen('', 'r');
?>
Solutions¶
Check the name of the file with empty() before using it with fopen().
Check the name of the file against ‘’ (empty string) before using it with fopen().
In more recent PHP versions, this error message is now Path cannot be empty.