具有多个文件扩展名的PHP if语句?
这存在于php文件中。我需要修改这一行代码,以便能够导航到dynamic/content_whatever.php,而不仅仅是.html 最好的方法是什么?谢谢。利用具有多个文件扩展名的PHP if语句?,php,html,Php,Html,这存在于php文件中。我需要修改这一行代码,以便能够导航到dynamic/content_whatever.php,而不仅仅是.html 最好的方法是什么?谢谢。利用glob()令人敬畏的支撑能力: if(!file_exists("dynamic/content_".$get.".html")) if (file_exists("dynamic/content_".$get.".html")) { include "dynamic/content_".$get.".html"; }
glob()
令人敬畏的支撑能力:
if(!file_exists("dynamic/content_".$get.".html"))
if (file_exists("dynamic/content_".$get.".html")) {
include "dynamic/content_".$get.".html";
} elseif (file_exists("dynamic/content_".$get.".php")) {
include "dynamic/content_".$get.".php";
}
帽尖
可能比使用file\u exists()
要慢一点,因为该函数非常快,而且还使用了,据我所知,glob()不使用。利用glob()
的强大支撑能力:
if (file_exists("dynamic/content_".$get.".html")) {
include "dynamic/content_".$get.".html";
} elseif (file_exists("dynamic/content_".$get.".php")) {
include "dynamic/content_".$get.".php";
}
帽尖
可能比使用file\u exists()
慢一点,因为该函数非常快,而且还使用了,据我所知,glob()不使用