The path of the current script ordinarily is provided to PHP by the Web server. The PHP function phpinfo() will print out a very nicely formatted report of the current environment that will help you understand some of the possibilities.
Apache provides the script filename, and you should be able to echo it like this:
echo $SCRIPT_FILENAME;
If you are running something other than Apache or if your PHP configuration has been altered, your mileage may vary.