Trying to get a full URL without filename in PHP

后端 未结 7 1723
鱼传尺愫
鱼传尺愫 2020-12-31 01:32

I thought this would be simple but I can\'t seem to find a variable of $_SERVER array that has what I\'m looking for.

Let\'s say my url is http://

7条回答
  •  北海茫月
    2020-12-31 02:14

    In your case, string manipulation is the best solution.

    For Example:

    substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1);
    

提交回复
热议问题