0
什麼是差異,我該如何解決這個問題。PHP file_get_contents()不工作如何修復
爲什麼這一個工作
$backupFile = file_get_contents("listbackup.json");
file_put_contents('list.json', $backupFile);
當我像這樣使用它不會工作。
這一個是上面的HTML
session_start();
if(!isset($_SESSION['active']))
{
$backup=fopen("backup/".time().".json", "w");
fwrite($backup, json_encode($list)); fclose($backup);
if(isset($backup))
{
$_SESSION['active']=true;
}
}
,當我試圖讓從$內容latest_filename它給了我一個假布爾,我不能得到任何後
session_start();
if(isset($_SESSION['active']))
{
$path= "backup";
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read()))
{
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime)
{
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$latest=file_get_contents($latest_filename);
file_put_contents('list.json', $latest);
session_destroy();
}
這個更勝一籌進一步與它。我需要的是將內容放入list.json中。
該死的我的壞,ahahahahah沒有看到那一個!非常感謝您的幫助 –
很高興幫助:) –