时间:2021-07-01 10:21:17 帮助过:24人阅读
C:\AppServ\www\YB-PHP\PathDemo\China\ShanDong\LinYi\03.php
要导入
C:\AppServ\www\YB-PHP\PathDemo\China\JiangSu\NanJing\NanJingEcho.php
就得写:
include('../../JiangSu/NanJing/NanJingEcho.php');
这样啰嗦不说,还老是容易弄错几个"../",每次我数这个,我都弄得好糊涂,怎么写简单点?
比如
C:\AppServ\www\YB-PHP\PathDemo\China\ShanDong\LinYi\03.php
要导入
C:\AppServ\www\YB-PHP\PathDemo\China\JiangSu\NanJing\NanJingEcho.php
就得写:
include('../../JiangSu/NanJing/NanJingEcho.php');
这样啰嗦不说,还老是容易弄错几个"../",每次我数这个,我都弄得好糊涂,怎么写简单点?
define('BASEPATH', 'C:\AppServ\www\YB-PHP\PathDemo\China\');
include(BASEPATH . 'JiangSu/NanJing/NanJingEcho.php');
psr4自动加载器
$_SERVER['DOCUMENT_ROOT'].'/JiangSu/NanJing/NanJingEcho.php'