本文介绍了PHP-获取当前URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个常见问题,但似乎没有一个是我要寻找的.如果有网站:

This seems like a common questions but none of them seem to be what i'm looking for. If there is a website:

www.example.com/test.php

www.example.com/test.php

我想拉"test.php",如果是这样的话:

I want to pull the "test.php" and if it's something like:

www.example.com/folder/folder1/test.php

www.example.com/folder/folder1/test.php

我想再次拉出"test.php",但是一切似乎都拉出了确切的路径,而不仅仅是页面.有什么建议吗?

I want again to just pull "test.php" but everything seems to pull the exact path instead of just the page. Any suggestions?

推荐答案

$query = $_SERVER['PHP_SELF'];
$path = pathinfo( $query );
$what_you_want = $path['basename'];

Voila.

这篇关于PHP-获取当前URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 18:39