Jun052012
php include绝对路径和相对路径常见用法
作者:黑♂白 发布:2012-06-05 21:08:44 分类: web后端
php include绝对路径和相对路径常见用法
绝对路径示例:
$droot="/var/www/html/";//网站根目录
//$droot="D:/xampp/htdocs/";//网站根目录
require_once($droot."include/cfg.php");
include($droot."include/cfg.php");
使用上文第一种绝对路径方法,该方法虽然笨拙,不大好看,对于小WEB程序够用即可。
相对路径示例:
require_once("../include/cfg.php");
include("../include/cfg.php");
require_once("../../../include/metsky/cfg.php");
include("../../../include/metsky/cfg.php");
表示包含上一级目录include下的cfg.php文件。
php include绝对路径和相对路径常见用法:目前有2 条留言
发表评论
您还未登录,需要登录后才能发言
分隔符最好用DIRECTORY_SEPARATOR。然后目录可以多用用常量来定义,哈哈。
2012-06-05 21:41:20真是这样的,常规做法了!
2012-06-06 14:39:02