我對PHP很陌生,我無法弄清楚爲什麼會發生這種情況。PHP退出後沒有加載頁面的其餘部分;
由於某種原因,當exit
觸發整個頁面停止加載時,不僅僅是PHP腳本。比如,它會加載頁面的上半部分,但是在腳本所在的位置以外沒有任何內容。
這裏是我的代碼:
$page = $_GET["p"] . ".htm";
if (!$_GET["p"]) {
echo("<h1>Please click on a page on the left to begin</h1>\n");
// problem here
exit;
}
if ($_POST["page"]) {
$handle = fopen("../includes/$page", "w");
fwrite($handle, $_POST["page"]);
fclose($handle);
echo("<p>Page successfully saved.</p>\n");
// problem here
exit;
}
if (file_exists("../includes/$page")) {
$FILE = fopen("../includes/$page", "rt");
while (!feof($FILE)) {
$text .= fgets($FILE);
}
fclose($FILE);
} else {
echo("<h1>Page "$page" does not exist.</h1>\n");
// echo("<h1>New Page: $page</h1>\n");
// $text = "<p></p>";
// problem here
exit;
}
'exit'停止所有頁面處理,就在那裏。 「死亡」也是如此。無論在何處或何時在代碼中,該行之後都不會運行。它等於'完全停止'。 –