0

How can I get in PHP the full path to the file?

For example:

 /home/yob/public_html/demo/envato/cce/tug/cron/cron.php

I want the folder where the file is:

 /home/yob/public_html/demo/envato/cce/tug/cron/
Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
DiegoP.
  • 45,177
  • 34
  • 89
  • 107
  • You know there's a search bar at the top of the site - This question has been answered plenty. – AlienWebguy Aug 09 '11 at 21:59
  • possible duplicate of [Get absolute path of current script](http://stackoverflow.com/questions/4645082/get-absolute-path-of-current-script) – Dan Grossman Aug 09 '11 at 22:00

1 Answers1

6

PHP < 5.3

$fullpath = dirname(__FILE__);

PHP >= 5.3

$fullpath = __DIR__;

http://php.net/manual/en/language.constants.predefined.php

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
  • No I did not explain good. I need to know the path of the website, of the folder where the file is, not the path of the file itself. I need the full path to the folder where this file is – DiegoP. Aug 09 '11 at 22:00