2
我想寫一個PHP文件,並設置它的權限,以便在其創建後立即編輯。PHP chmod使用
這裏是我的代碼:
<?php
$var = '<?php $mycontent = new Content(); echo $mycontent->block($p_name);?>';
$myFile = "testFile.php";
$fh = fopen($myFile, 'w+') or die("can't open file");
$stringData = $var;
fwrite($fh, $stringData);
fclose($fh);
chmod("tests/testFile.php", 0644);
?>
出於某種原因,它不工作。創建的文件仍然不可編輯,除非手動設置權限。 tests /是創建文件的目錄。
有什麼想法?
創建文件的腳本位於創建文件的同一文件夾中。我試過但不工作:$ myFile =「testFile.php」; $ fh = fopen($ myFile,'w +')或死(「無法打開文件」); chmod(「testFile.php」,0644); – Mauro74 2011-03-07 23:22:00
您是否嘗試將其設置爲0777,或者之後手動檢查文件權限以查看腳本是否實際影響正確的文件? – Sam152 2011-03-07 23:25:04
感謝Sam,它現在可以使用0777權限。 :) – Mauro74 2011-03-08 08:19:08