开发者

php __DIR__ to other location

开发者 https://www.devze.com 2022-12-13 09:58 出处:网络
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?

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

精彩评论

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