dirname和include_once

这样写的效果是一样的

include_once dirname(dirname(__FILE__)) . " /define.php";
include_once dirname(dirname(__FILE__)) . " \define.php";

__FILE__ 和 __DIR__ 的区别 

<?php  $dir = dirname(__FILE__);  ?>
在PHP5.3中,增加了一个新的常量__DIR__,指向当前执行的PHP脚本所在的目录。
例如当前执行的PHP文件为 /www/website/index.php
则__FILE__等于‘/www/website/index.php‘
而__DIR__等于‘/www/website‘
 

所以刚开始也可以这样写

   include_once dirname(__DIR__) . "/define.php";
        include_once dirname(__DIR__) . "\define.php";

猜你喜欢

转载自www.cnblogs.com/starshine-zhp/p/13204460.html
今日推荐