Couldn’t open stream: %s¶
Description¶
When opening a stream, or file, a mode of operation is needed.
There are several valid modes: ‘r’, ‘r+’, ‘w’, ‘w+’, ‘a’, ‘a+’, ‘x’, ‘x+’, ‘c’, ‘c+’, ‘e’. Check docs for details about them.
All other strings are not supported, and yield this error.
Example¶
<?php
//`+k' is not a valid mode for fopen
// k is not an open option
fopen($path, '+k');
//`wr' is not a valid mode for fopen
// write-only w and read-only r are mutually exclusive
fopen($path, 'wr');
?>
Literal Examples¶
Couldn’t open stream: ‘+k’ is not a valid mode for fopen
Couldn’t open stream: Is a directory
Couldn’t open stream: Inappropriate ioctl for device
Couldn’t open stream: Invalid argument
Solutions¶
Use only valid stream open modes.
See Also¶
In previous PHP versions, this error message used to be Couldn’t open stream %s.