删除文件名中的前导斜杠和 .php
下面的代码为我提供了我所在页面的文件名,例如“/index.php”,我想知道如何将其修剪为没有 / 和 .php 的索引。
$pageName = $_SERVER['SCRIPT_NAME'];
echo $pageName;
我使用它来输出我所在位置的简单站点面包屑。
提前致谢。
The code below gives me the file name of the page I'm on e.g. '/index.php' I want to know how I can trim this to be just index without the / and the .php.
$pageName = $_SERVER['SCRIPT_NAME'];
echo $pageName;
I'm using this to output the location of where I am for a simple site breadcrumb.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
pathinfo
(需要 php 5.2+):或者,对于不太灵活的解决方案,请使用 php 的字符串函数和
basename
:Use
pathinfo
(requires php 5.2+):Alternatively, for a less flexible solution, use php's string functions and
basename
: