我卡住了。一直試圖解決這個問題。這個例子幾乎和老師一樣......我不明白.... html是here。它的時間表簡單的設置。它不會正確寫入文件。幫幫我?PHP fwrite錯誤
編輯:它不會將變量寫入文件。我可以讓它寫文本,而不是變量。希望澄清。
<?php
/* Create folder for data */
if (is_dir('schedule'))
chdir('schedule');
else
{mkdir('schedule');
chdir ('schedule');}
/* Variable Declaration */
/* Employee 1 */
$sunStart1=$_POST['sunStart1'];
$sunEnd1=$_POST['sunEnd1'];
$monStart1=$_POST['monStart1'];
$monEnd1=$_POST['monEnd1'];
$tuesStart1=$_POST['tuesStart1'];
$tuesEnd1=$_POST['tuesEnd1'];
$wedStart1=$_POST['wedStart1'];
$wedEnd1=$_POST['wedEnd1'];
$thurStart1=$_POST['thurStart1'];
$thurEnd1=$_POST['thurEnd1'];
$friStart1=$_POST['friStart1'];
$friEnd1=$_POST['friEnd1'];
$satStart1=$_POST['satStart1'];
$satEnd1=$_POST['satEnd1'];
/* Employee 2 */
$sunStart2=$_POST['sunStart2'];
$sunEnd2=$_POST['sunEnd2'];
$monStart2=$_POST['monStart2'];
$monEnd2=$_POST['monEnd2'];
$tuesStart2=$_POST['tuesStart2'];
$tuesEnd2=$_POST['tuesEnd2'];
$wedStart2=$_POST['wedStart2'];
$wedEnd2=$_POST['wedEnd2'];
$thurStart2=$_POST['thurStart2'];
$thurEnd2=$_POST['thurEnd2'];
$friStart2=$_POST['friStart2'];
$friEnd2=$_POST['friEnd2'];
$satStart2=$_POST['satStart2'];
$satEnd2=$_POST['satEnd2'];
/* Make data file */
$schedule = fopen('schedule.txt', 'w');
fwrite($schedule, "$sunStart1\n");
fwrite($schedule, "$sunEnd1 \n");
fwrite($schedule, "$monStart1 \n");
fwrite($schedule, "$monEnd1 \n");
fwrite($schedule, "$tuesStart1 \n");
fwrite($schedule, "$tuesEnd1 \n");
fwrite($schedule, "$wedStart1 \n");
fwrite($schedule, "$wedEnd1 \n");
fwrite($schedule, "$thurStart1 \n");
fwrite($schedule, "$thurEnd1 \n");
fwrite($schedule, "$friStart1 \n");
fwrite($schedule, "$friEnd1 \n");
fwrite($schedule, "$satStart1 \n");
fwrite($schedule, "$satEnd1 \n");
fwrite($schedule, "$sunStart2 \n");
fwrite($schedule, "$sunEnd2 \n");
fwrite($schedule, "$monStart2 \n");
fwrite($schedule, "$monEnd2 \n");
fwrite($schedule, "$tuesStart2 \n");
fwrite($schedule, "$tuesEnd2 \n");
fwrite($schedule, "$wedStart2 \n");
fwrite($schedule, "$wedEnd2 \n");
fwrite($schedule, "$thurStart2 \n");
fwrite($schedule, "$thurEnd2 \n");
fwrite($schedule, "$friStart2 \n");
fwrite($schedule, "$friEnd2 \n");
fwrite($schedule, "$satStart2 \n");
fwrite($schedule, "$satEnd2 \n");
fclose ($schedule);
?>
「它不會正確寫入文件」 - 給我們一個線索?預期的結果是什麼,你得到了什麼? – craig1231 2012-02-12 22:18:02
有沒有具體的錯誤? – Joel 2012-02-12 22:18:18
這有幫助嗎? – 2012-02-12 22:19:59