我有这个代码:
$file = '/path/to/file.txt';
if (($fd = fopen($file, "a") !== false)) {
fwrite($fd, 'message to be written' . "\n");
fclose($fd);
}
Run Code Online (Sandbox Code Playgroud)
为什么我会收到以下警告?
fwrite(): supplied argument is not a valid stream resource
fclose(): supplied argument is not a valid stream resource
Run Code Online (Sandbox Code Playgroud)
你的if语句错了.尝试
if (($fd = fopen($file, "a")) !== false) {
Run Code Online (Sandbox Code Playgroud)
因为你的一个就像
$fd = fopen($file, "a") !== false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9403 次 |
| 最近记录: |