Path 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.

Example

<?php

fopen('', 'r');

?>

Literal Examples

  • fopen(): Path cannot be empty

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 must not be empty.