Get a local path using PHP
Can I get a path like this using PHP ?
c:\\wamp\\www\\mysite\\blabla\n
from the script running in "mysite" or mysite/blabla
basically I want to f开发者_如何学Pythonind the full file path, not just the one from the server, which in this case is located in www :)
You should use dirname(__FILE__)
. You can also use just __DIR__
as of PHP 5.3
Really simple!
print $_SERVER['SCRIPT_FILENAME'];
do a print_r on $_SERVER and check it out :)
__FILE__
magic constant. Works for PHP >= 4.0.2
精彩评论