2013-02-14 47 views

回答

0
<?php   
$filename = "/find"; 
if (is_dir($filename)){ 
echo $filename, " display html1 "; 
include('html1.html'); 
} 
else{ 
echo $filename, " display html2 "; 
include('html1.html'); 
} 
?> 

此代碼檢查文件夾「find」是否存在,它顯示html1 else html2。

我想更好的選擇,你會是這樣:

使用的htaccess當用戶browse http://yourdomain/about/whatever顯示從http://yourdomain/page.php?p=about&var=whatever

內容,並使用$_GET['p']得到你的頁面p的價值,並顯示html相應地

if($_GET['p'] == "find"){ 
    include('html1.html'); 
}else{ 
    include('html2.html'); 
} 
+0

檢查目錄中是否有文件。我不希望它找到一個文件。我只想讓php代碼看到用戶是否在目錄中,然後顯示什麼樣的html。 – Mike 2013-02-14 04:41:56

+0

它實際上檢查文件夾「查找」,你真的有一個查找和約文件夾,或者你使用htaccess重定向。 – 2013-02-14 04:44:26

+0

檢查編輯的答案:) – 2013-02-14 04:50:06