PHP Get URL with Parameter

后端 未结 5 1055
迷失自我
迷失自我 2021-02-01 15:45

I want to get a URL and its parameters. Example:

www.someweb.com/somepage.php?id=10

How to get only

5条回答
  •  囚心锁ツ
    2021-02-01 16:05

    function curPageName() {
     return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
    }
    echo "The current page is ".curPageName()."?".$_SERVER['QUERY_STRING'];
    

    This will get you page name , it will get the string after the last slash

提交回复
热议问题