当前位置: 代码迷 >> PHP >> 怎么检查页面URL中是否有某个字符串
  详细解决方案

怎么检查页面URL中是否有某个字符串

热度:24   发布时间:2016-04-29 01:12:07.0
如何检查页面URL中是否有某个字符串?
鉴于安全,想获取本页面的url,检查里面是否有“script”这个字符串,若有则禁止访问或退出。该如何实现?

------解决方案--------------------
strstr strpos
------解决方案--------------------
you should have a html parser...
------解决方案--------------------
you should have a html parser. I suppose there are such php version in the wild.
------解决方案--------------------
PHP code
  function curPageURL(){    $pageURL = 'http';    if ($_SERVER["HTTPS"] == "on")    {        $pageURL .= "s";    }    $pageURL .= "://";    if ($_SERVER["SERVER_PORT"] != "80")    {        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];    }    else    {        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];    }    return $pageURL;}
  相关解决方案