php里面能否嵌套php,嵌套包含PHP

我遇到嵌套包含问题.虽然我看到有一些类似的问题,但它们似乎没有帮助.

一般来说,我没有包含问题,但最近我一直在尝试新的东西,我无法让嵌套的包含工作.

基本设置:

> index.php包含’/include/header.php’

> header.php包含’/resources/login/index_alt.php’

> index_alt.php包含’/resources/login/index_auth.php’

> index_auth.php包含’/class/Login.class.php’和

‘/class/Connection.class/php’

我实际上并没有写这样的路径(它是为了理解深度).

这就是它在页面上的外观.

index.php文件:

> include(‘include / header.php’);

header.php :(除了/ resources / …之外,每个深度级别都包含头文件)

> include(‘../ resources / login / index_alt.php’);

index_alt.php:

> include(‘index_auth.php’);

index_auth.php:

> include(‘../../ class / Login.class.php’);

> include(‘../../ class / Connection.class.php’);

在某些深度级别,头文件被接受,但包括嵌套将不…

解决方法:

假设文件系统看起来像这样..

/www

include/header.php

class/Login.class.php

class/Connection.class.php

resources/login/index_alt.php

resources/login/index_auth.php

index.php

这意味着

index.php: include(__DIR__ . '/include/header.php');

header.php: include(__DIR__ . '/../resources/login/index_alt.php');

index_alt.php: include(__DIR__ . '/index_auth.php');

标签:php,include,nested,require

来源: https://codeday.me/bug/20190826/1727973.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值