因此,我有一個簡單的網頁,在頁眉和頁腳部分(不同風格的頁面和頁腳部分)中使用動態生成的菜單。我使用php包含頁眉和頁腳塊。所以,我遇到了一個問題:由於樣式不同,我需要只在其他頁面上看到頁眉和頁腳塊,而不是第一個 - 主頁。我試圖做到:if(content ==「home」){echo .header,.footer {display:hidden;「};但是當我第一次加載頁面時它不起作用!也許你們有一些想法?謝謝你提前在第一頁隱藏頁眉和頁腳,但在其他頁面顯示編輯
這裏是我的代碼:
<?php
$languages = array("eng","lat", "ru");
$sections = array("home", "about", "cafe", "catering", "gallery", "contact");
$sectionTitles = array("eng" =>array("ABOUT US", "CAFE MENU"), "lat"=>array("PAR MUMS", "ĒDIENKARTE"), "ru" =>array("ru1","ru2",));
$lang = "eng";
$section = "home";
$content = explode("/", $_SERVER['REQUEST_URI']);
if (!empty($content[2]) && (in_array($content[2], $languages))) { $lang = $content[2];}
if (!empty($content[3]) && (in_array($content[3], $sections))) { $section = $content[3];}
$sectionTitles = $sectionTitles[$lang];
require_once ("header.php");
require_once ("$lang/$section.php");
require_once ("footer.php");
?>
頭文件
<div class="header">Some header info+menu. Not visible on first page</div>
內容文件:
<div class="content">Content different for every page.</div>
頁腳文件:
<div class="footer">Footer info+page map. Not visible on first page.</div>
喜請檢查鏈接http://stackoverflow.com/questions/3952590/php-how-to-find-application-root ..會對你有所幫助 – Renjith