檢查的權限爲可寫或不 嘗試這個例子,不是看你是否得到任何輸出或不
<?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 =在 這表明沒有錯誤 –