[英]PHP get grandfather dir path
I know PHP > 5.3 added the Magic constants : __DIR__
to get the father dir path, 我知道PHP> 5.3添加了Magic常量:
__DIR__
来获取父目录路径,
But how can I get the grandfather dir path in a smarter way? 但是,我怎样才能以更智能的方式获得祖父的路径?
1. __DIR__.'/../'
1.
__DIR__.'/../'
2. dirname(__DIR__)
2.
dirname(__DIR__)
You can simply move up a folder by using ..
. 您可以使用
..
简单地向上移动文件夹。
For example: 例如:
$path = dirname(__DIR__);
$grandfatherPath = $path.'/../../';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.