PHP take arguments from URL path

前端 未结 4 2147
南笙
南笙 2021-01-05 14:34

Say I have a url like this:

http://www.mysite.com/forum/board1/sub-forum/topics/123

Is there a simple way in PHP (can\'t use HTAccess) to take t

4条回答
  •  误落风尘
    2021-01-05 15:16

    explode('/', getenv('REQUEST_URI'));
    

    If your environment happens to include the query string part in the above value, here's a neat workaround:

    explode('/', strtok(getenv('REQUEST_URI'), '?'));
    

提交回复
热议问题