Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有多个文件扩展名的PHP if语句?_Php_Html - Fatal编程技术网

具有多个文件扩展名的PHP if语句?

具有多个文件扩展名的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"; }

这存在于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";
} 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()不使用