[英]Get path from URL
Looking for a way of getting the path from an URL in PHP: 寻找一种从PHP中的URL获取路径的方法:
I want to take: http://example.com/hurrdurr
我想采取:
http://example.com/hurrdurr
: http://example.com/hurrdurr
And make it: hurrdurr
并且做到:
hurrdurr
I only want the text after .com/
我只想要
.com/
之后的文字
Can i do this with trim? 我可以用修剪来做到这一点吗?
For this particular case you could also use "basename" for your purposes. 对于这种特殊情况,您也可以使用“basename”来达到目的。
$var='http://twitter.com/pwsdedtch';
echo basename($var);
// pwsdedtech
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.