John
John

Reputation: 291

php relative path needed till project name

I am trying to get relative path of my project, but not exactly as required.

I have a directory structure like : '/opt/www/myproj/folder1/folder2/myfile.php'

So in myfile.php I am trying to get path till my project ie., /opt/www/myproj

I have tried differnt ways like using $_SERVER["DOCUMENT_ROOT"], dirname(__FILE__), basename(__FILE__) etc.. but still no luck.

When I used $_SERVER["DOCUMENT_ROOT"], iam getting path till /opt/www/

Could anyone please tell me how can I achieve above..

Upvotes: 1

Views: 25

Answers (1)

Fabio Cardoso
Fabio Cardoso

Reputation: 1269

Try this:

echo getcwd() . "\n";

Upvotes: 1

Related Questions