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.
精彩评论