gpt4 book ai didi

php - 我怎么知道是否是 require_once?

转载 作者:行者123 更新时间:2023-12-02 22:38:22 25 4
gpt4 key购买 nike

我有两个文件

1 - index.php2 - main.php

index.php 通过<?php require_once("../../includes/main.php"); ?> 调用ma​​in.php

我怎么知道 ma​​in.php 什么时候执行,

如果 index.php 调用他或同一用户独立执行它?
如果是 require_once,我应该在 main php 中询问什么以继续运行程序?

最佳答案

我之前通过在包含之前设置一个变量,然后执行包含来做到这一点。例如:

$included_main_from = 'index.php';
require ('../../includes/main.php');

然后在 main.php 中检查该变量及其值。

关于php - 我怎么知道是否是 require_once?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11106938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com