0
if(!file_exists("dynamic/content_".$get.".html"))
這存在於一個php文件中。我需要修改這一行代碼,以便能夠導航到dynamic/content_whatever.php,而不僅僅是.html。PHP if語句具有多個文件擴展名?
這樣做的最好方法是什麼?謝謝。
if(!file_exists("dynamic/content_".$get.".html"))
這存在於一個php文件中。我需要修改這一行代碼,以便能夠導航到dynamic/content_whatever.php,而不僅僅是.html。PHP if語句具有多個文件擴展名?
這樣做的最好方法是什麼?謝謝。
if (file_exists("dynamic/content_".$get.".html")) {
include "dynamic/content_".$get.".html";
} elseif (file_exists("dynamic/content_".$get.".php")) {
include "dynamic/content_".$get.".php";
}
。利用3210的真棒撐能力:
if (count(glob("dynamic/content_$get.{php,html,txt,htm}", GLOB_BRACE)) == 0)
...
帽尖到Gumbo
可能比使用file_exists()
慢一點,因爲該功能是非常快,另外使用stat cache,據我所知,glob()不。
:) – Gumbo 2010-08-23 21:31:00