Last active
August 29, 2015 13:57
-
-
Save raynimmo/e27ba70e3f19a35fb77b to your computer and use it in GitHub Desktop.
PHP file paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__FILE__ (on Hosting) === /home/xfiddlec/public_html/folder1/folder2/yourfile.php | |
__FILE__ (on Localhost) === C:\wamp\www\folder1\folder2\yourfile.php | |
$_SERVER['HTTP_HOST'] === www.yoursite.com (or without WWW) | |
$_SERVER["PHP_SELF"] === /folder1/folder2/yourfile.php | |
$_SERVER["REQUEST_URI"] === /folder1/folder2/yourfile.php?var=blabla | |
$_SERVER["DOCUMENT_ROOT"] === /home/xfiddlec/public_html | |
//basename returns the last filename | |
basename('/folder1/folder2/yourfile.php') {i.e. basename(__FILE__) ==== yourfile.php | |
//dirname returns the part upper part, without filename [same as getcwd()] | |
dirname('/folder1/folder2/yourfile.php') {i.e. dirname(__FILE__) ==== /folder1/folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment