检查的权限为可写或不 尝试这个例子,不是看你是否得到任何输出或不
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
是共享主机,他们是否禁用了allow_url_fopen? http://php.net/manual/en/filesystem.configuration.php“如果启用了fopen包装,你只能使用fopen()来访问远程文件。该参数在php.ini文件中指定,不能更改在运行时使用ini_set“ – ArtisticPhoenix
有没有关于错误的任何信息? – John
是自配置在AWS上bitnami服务器上的php.ini它具有: 了allow_url_fopen =在 这表明没有错误 –