加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP require_once或include_once嵌套

发布时间:2020-12-13 17:06:48 所属栏目:PHP教程 来源:网络整理
导读:目录结构, A.php 文件夹 B.php C.php A.php包括B.php和B.php包括C.php. 但B.php需要包括相对于A.php的C.php.有没有什么方法可以包括相对于B.php的C.php? 解决方法 您可以包括使用__DIR__或dirname(__ FILE__). 从the manual起 The directory of the file. I
目录结构,

> A.php
>文件夹

> B.php
> C.php

A.php包括B.php和B.php包括C.php.

但B.php需要包括相对于A.php的C.php.有没有什么方法可以包括相对于B.php的C.php?

解决方法

您可以包括使用__DIR__或dirname(__ FILE__).

从the manual起

The directory of the file. If used
inside an include,the directory of
the included file is returned. This is
equivalent to dirname(__FILE__).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读