开发者

php __DIR__ to other location

Sa开发者_JS百科y I have echo realpath( dirname(__DIR__) ); that points me to /usr/location

How can I use the same mechanism to point to /usr/otherplace?

Thank you, Tee


The question isn't totally clear, so I am answering it how I took it.

A simple method is to allow the file system to sort it out and just append /../otherplace

realpath( dirname(__DIR__) ) . '/../otherplace';

Otherwise you are going to have to parse the file string, which the simplest method is to use explode(), manipulate the array (In this case setting the last element to otherplace) and then use implode() to reassemble it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜