PHP-当前文件夹/目录名称 [英] PHP - current folder / directory name
本文介绍了PHP-当前文件夹/目录名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取PHP中的当前文件夹/目录名称?
how can I get the current folder/directory name in PHP?
我的网站上有两个页面:
I have two pages on my site:
/about
和/help
这是我的代码(在关于"和帮助"页面中):
This is my code (in about and help page):
<?php
echo dirname("index.php");
?>
如果我在关于"页面上,我希望它返回:关于".如果我在帮助页面上,则返回帮助".但是它什么也没返回.
I want it to return: 'about' if I am on about page. And return 'help' if I am on help page. But it returns nothing.
如果我在这条道路上: http://www.website.com/about/index.php
我希望它只返回 about
If I am on this path:
http://www.website.com/about/index.php
I want it to just return about
推荐答案
getcwd();
或
dirname(__ FILE __);
或(PHP5)
基本名称(__DIR __)
http://php.net/manual/en/function.getcwd.php
http://php.net/manual/en/function.dirname.php
这篇关于PHP-当前文件夹/目录名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文