teepusink
teepusink

Reputation: 28892

php __DIR__ to other location

Say 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

Upvotes: 0

Views: 277

Answers (1)

Yacoby
Yacoby

Reputation: 55465

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.

Upvotes: 2

Related Questions