PHP How to get Full Path to the file included home and user

♀尐吖头ヾ 提交于 2019-12-25 03:21:49

问题


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/

回答1:


PHP < 5.3

$fullpath = dirname(__FILE__);

PHP >= 5.3

$fullpath = __DIR__;

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



来源:https://stackoverflow.com/questions/7003491/php-how-to-get-full-path-to-the-file-included-home-and-user

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!