Home >Backend Development >PHP Tutorial > 怎么截取url上面最后的地址

怎么截取url上面最后的地址

WBOY
WBOYOriginal
2016-06-13 13:39:19975browse

如何截取url上面最后的地址?
http://forum.csdn.net/PointForum/Forum/test.aspx

比如这个url上面最后的test.aspx。

除了用substr()还有什么方法吗?

php应该有这样的函数把?

一般都是怎么做的?

------解决方案--------------------

PHP code

<?php $path="http://forum.csdn.net/PointForum/Forum/test.aspx";
//basename函数,返回文件名部分
echo basename($path).PHP_EOL;
//pathinfo(),返回文件路径的相关信息
echo pathinfo($path,PATHINFO_BASENAME);
?> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn