Home >Backend Development >PHP Tutorial >怎么检查页面URL中是否有某个字符串

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

WBOY
WBOYOriginal
2016-06-13 10:23:471063browse

如何检查页面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;}<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn