Best method for creating absolute path in PHP? (See 3 methods listed inside)
- by mark
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!