我使用PHP來幫助創建網頁表,並且似乎無法找到此while循環崩潰瀏覽器的位置。使用while循環崩潰我的瀏覽器,PHP
<?php
$counter1 = 1;
$weekDay = date('l');
echo "Today is $weekDay " . date("Y/m/d") . "<br/>";
echo "<h1>Table Construction</h1>";
echo "<table><tr>";
$dateNow = date("Y/m/d");
$dayStore = array();
while ($counter1 < 8) {
$stringCheck = "+" . $counter1 . " day";
$dateMod = strtotime($stringCheck, strtotime($dateNow));
$weekDay = date ('D',$dateMod);
echo "<td id=\"bolder\">" . date ('l',$dateMod) . " " . date("Y/m/d", $dateMod). "</td>";
$dayStore[$counter1]=$weekDay;
$counter1++;
}
echo "</tr>";//"<tr>";
$counter1=1;
while ($counter1<8){
echo "<td><form name=\"timeslots\">";
$dayVar = $dayStore[$counter1];
echo $dayVar. " ";
$counterHours = 0;
if ($dayVar == "Mon"||$dayVar == "Tue"||$dayVar == "Wed"||$dayVar == "Thu"||$dayVar == "Fri") {
$startTime = 9;
$counterHours = 0;
while ($counterHours<3) {
$timeString = $startTime . ":00 am";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input><br/>";
$startTime = $startTime+1;
$counterHours++;
}
while (startTime<12 && $counterHours>=3) {
$timeString = ($startTime-12) . ":00 pm";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input>";
$startTime = $startTime+1;
$counterHours++;
}
}
else if ($dayVar == "Sat") {
$startTime = 9;
$counterHours = 0;
while ($counterHours<3) {
$timeString = $startTime . ":00 am";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input>";
$startTime = $startTime+1;
$counterHours++;
}
while ($counterHours<12 && $counterHours>=3) {
$timeString = ($startTime-12) . ":00 pm";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input>";
$startTime = $startTime+1;
$counterHours++;
}
}
else if ($dayVar == "Sun") {
$startTime = 11;
$counterHours = 0;
while ($counterHours<3) {
$timeString = $startTime . ":00 am";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input>";
$startTime = $startTime+1;
$counterHours++;
}
while ($counterHours<12 && $counterHours>=3) {
$timeString = ($startTime-12) . ":00 pm";
echo "<input type=\"radio\" name=\"$dayStore[$counter1]\" value=\"$startTime\">$timeString</input>";
$startTime = $startTime+1;
$counterHours++;
}
}
else {
echo "displaying a proper message";
}
echo "</form></td>";
$counter1++;
}
echo "</tr></table>";
?>
當我在主頁面上傳到我的學校的服務器並運行它時,沒有任何加載和瀏覽器崩潰。隨着我選擇的變量範圍,我不認爲它應該做的是...
你有什麼錯誤嗎? (1.你的常量'startTime'定義在哪裏?100塊錢,你沒有定義這個常量,你想用你的變量名稱) – Rizier123
我得到錯誤說'undefined constant startTime'請定義它 – spiderman
當看到包含「Crashing my browser」的標題的「Run code snippet」時,有沒有其他人感到不安? ;) –