Best method for creating absolute path in PHP? (See 3 methods listed inside)

Posted by mark on Stack Overflow See other posts from Stack Overflow or by mark
Published on 2010-05-23T19:23:53Z Indexed on 2010/05/23 19:30 UTC
Read the original article Hit count: 105

Filed under:
|

I can create paths with no problem, but I want to know which of these 3 methods is the most rock solid and reliable and will work on the most servers.

Right now I am using method 1 in my script and some users are having path issues. I just want the method that will work on any version of php and almost any server config.

1.  <?php echo $_SERVER['DOCUMENT_ROOT']; ?>

2.  <?php echo getcwd(); ?>

3.  <?php echo dirname(__FILE__); ?>

Thank you so much for any expertise you can provide about this!

© Stack Overflow or respective owner

Related posts about php

Related posts about path