【问题标题】:How to use require_once to only load the variables from remote page, then prevent further execution of remote page?如何使用 require_once 仅从远程页面加载变量,然后阻止远程页面的进一步执行?
【发布时间】:2019-12-21 06:26:28
【问题描述】:

我正在使用require_once 从另一个页面加载一些变量值,但是,在“远程”页面的底部是另一个require_once,它从另一个页面加载函数。

我试图阻止“远程”页面底部的require_once at 被执行。在我检索到所需的变量值后,是否有任何方法可以阻止页面执行?

【问题讨论】:

  • 如果只是加载函数,有什么问题?只是不要调用这些函数。
  • 感谢您的回复,感谢您的建议,我知道它们会正常工作。我知道其他选项,但是,我正在寻找解决这个问题的方法。

标签: php codeigniter-3 require-once


【解决方案1】:

将文件读入变量,去掉require_once这一行,然后调用eval()执行。

$code = file_get_contents('otherpage.php');
$code = preg_replace('/require_once.*;/i', '', $code);
eval($code);

【讨论】:

    猜你喜欢
    • 2021-10-02
    • 1970-01-01
    • 2010-10-16
    • 1970-01-01
    • 2012-06-22
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-08-04
    相关资源
    最近更新 更多