【发布时间】:2015-02-14 19:39:29
【问题描述】:
我有以下代码:
<?php
$myfile = fopen("code2.css", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
?>
code2.css 与我的 PHP 文件在同一个文件夹中,但它抛出了我:
始终无法打开文件。
我该如何解决这个问题?
更新:使用权限播放后错误消失了,但我的文件仍然不会更新。
【问题讨论】:
-
也许删除代码末尾的
?>? -
好像你有 1 个
?>太多了。 -
检查文件权限。
-
@Fres-ii- 如何在 localhost 中做到这一点
-
@stranger4js 这应该可以:
echo substr(sprintf('%o', fileperms('code2.css')), -4);