如果URL在URL中有X,则执行Y.

时间:2016-02-14 00:11:12

标签: php

现在我使用此代码检查?spt=01的网址:

if(isset($_GET['spt']) && $_GET['spt']=='01'){ 
    include('01.php');
}

但是,我宁愿做的是检查文件名末尾的URL。

实施例: http://example.com/folder/subfolder/page-name-goes-here.php

那么如何查看-name-的网址然后我才能执行php include('01.php')

1 个答案:

答案 0 :(得分:0)

您想要检查$_SERVER['REQUEST_URI']数组http://php.net/manual/en/reserved.variables.server.php

中的$_SERVER