How To Identify The Requested Page In PHP

后端 未结 5 1455
栀梦
栀梦 2021-02-04 04:59

Is there any easy way to identify the file initially handling the request, ignoring get arguments and handling (at least basic) mappings like / to /index.php<

5条回答
  •  时光取名叫无心
    2021-02-04 05:43

    Go get file name from the requested URL use following code.

    basename($_SERVER['URL']);
    basename($_SERVER['REQUEST_URI']);
    basename($_SERVER['SCRIPT_NAME']);
    basename($_SERVER['SCRIPT_FILENAME']);
    basename($_SERVER['REQUEST_URI']);
    basename($_SERVER['PATH_TRANSLATED']);
    basename($_SERVER['PHP_SELF']);
    

    use any one all all of those in the nested if condition so you will not miss file name any how.

提交回复
热议问题