我正在測試php,因爲我是這個問題的新生。我把我的php代碼放在一個免費的服務器上,他們讓我做我自己的index.php,管理一些php變量(比如register_globals,magic_quotes_gpc等,我把它們作爲默認值),但顯然我可以處理一個以上的文件PHP代碼,例如:在PHP中管理多個文件
<?php
//--------Updating Data-------------
$cdc = intval($_POST['cantidadDeCapitulos']);
$toWrite = array('ctot' => $cdc);
for($i=1;$i<$cdc+1;$i += 1){
$toWrite["cap".$i] = $_POST['numdeCap'.$i];
}//---------------------------------
$datos = file_get_contents("myfile.json.");
$toWrite = json_encode($toWrite);
//Open a file in write mode
$fp = fopen("myfile2.json", "w");
if(fwrite($fp, "$toWrite")) {
echo "&verify=success&";
} else {
echo "&verify=fail&";
}
fclose($fp);
?>
如果我註釋掉線$datos = file_get_contents("myfile.json.");
這是正常的!東西是寫在myfile2.json但如果取消註釋,數據不會被更新。這兩個文件都具有權限666,並且它們位於相同的目錄中,即/ root。
嘗試777 666 – RobinJ
@RobinJ 666代替仍將允許寫作。 – SomeKittens
@SomeKittens我知道,但我想你可能需要執行權限。 – RobinJ