我並不認爲自己擅長使用php,所以那些專家請不要爲我的noob方法而抨擊我。我在嘗試學習。鏈接到php包含的網頁返回主頁
有段時間,有人告訴我如何分解部分網頁,並將它們編寫爲包含,這樣我就不會爲每個頁面重新繪製頁眉,頁腳和導航。截至昨天上午,我的網頁加載得很好,並且已經有很多年了。但是,似乎出現了問題,可能在我的服務器上,現在所有頁面都會轉到主頁。
我有我的網頁設置爲這樣:
的index.php
<?php
if (! isset($HTTP_GET_VARS['content']) || ! $HTTP_GET_VARS['content']){
$content="squeeze";
}
else
$content=$HTTP_GET_VARS['content'];
//1
if ($content == "do-you-have-success-habits"){
$page_title="Do You Have Success Habits?";
$keywords="Booking Agent Book, Music Business Career Development Information, Performing Arts Entertainment Information";
$desc="Music Business Booking Management artist career development for musicians, performing artists, agents and managers";
$style="../scripts/style.css";
$popupjs="none";
$storbutnjs="none";
$retreatjs="none";
$rolloverjs="none";
$readform_chkjs="none";
$logo="req-files/logo.html";
$navbar="req-files/navbar.html";
$sidebar="req-files/sidebar.html";
$main="weekly/2013/do-you-have-success-habits.html";
}
include ("req-files/head.html");
include ($logo);
include ($navbar);
include ($sidebar);
include ($main);
include ("req-files/footer.html");
?>
這是什麼,我有一個切碎的版本。整個index.php都有這樣寫的頁面,但是它也包含了其他的php頁面。有這麼多的內容,這個網站,我不得不建立一個頁面內的類似信息的PHP頁面...... I.E.所有的分支機構會進入affiliates.php,然後包含在我的index.php中。
// INCLUDE AFFILIATES HERE
include ("affiliates.php");
我希望這是足夠的信息來幫助我解決我的問題。
我的作品樣本就像這個頭文件。我的變量在片斷中。
head.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print $page_title ?></title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="author" content=" " />
<meta name="keywords" content="<?php print $keywords ?>" />
<meta name="description" content="<?php print $desc ?>" />
<meta name="copyright" content="2006-2013" />
<link rel="stylesheet" type="text/css" href="<?php print $style ?>" />
<link href="scripts/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqLtHdr #sidebar1 { padding-top: 30px; }
.twoColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<link rel="stylesheet" type="text/css" href="scripts/style.css" />
<script src="scripts/stuHover.js" type="text/javascript"></script>
<link href="scripts/dropdown_menu.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.png" />
<?php
if ($popupjs != "none") {
print("<script src=\"${popupjs}\">");
print("</script>\n");
}
if ($storbutnjs != "none") {
print(" <script src=\"${storbutnjs}\">");
print("</script>\n");
}
if ($retreatjs != "none") {
print(" <script src=\"${retreatjs}\">");
print("</script>\n");
}
if ($rolloverjs != "none") {
print(" <script src=\"${rolloverjs}\">");
print("</script>\n");
}
if ($readform_chkjs != "none") {
print(" <script src=\"${readform_chkjs}\">");
print("</script>\n");
}
?>
</head>
如前所述,我初出茅廬用PHP。所以,我無法理解爲什麼我的導航欄中鏈接的頁面將返回頁面(擠壓)。
現在,我的託管技術支持指出,它可能是不推薦使用的代碼,導致它失敗。他們正在遷移我的網站,可能是以前的版本的PHP。但我需要知道從哪裏開始解決這個問題。我希望這是一個簡單的修復,因爲這個網站是巨大的!
謝謝你的耐心和你的幫助。
海蒂
我們需要看到發生問題的$ navbar include文件。 – DrCord
這可能有所幫助:http://stackoverflow.com/questions/8920438/php-include-file-that-has-includes – DrCord
在我給出的這個特定的例子中,有兩個導航系統。 – Heidi