gpt4 book ai didi

php 在获取文件内容之前评估代码

转载 作者:可可西里 更新时间:2023-11-01 00:06:06 25 4
gpt4 key购买 nike

我有一个文件 B590.php,它有很多 html 代码和一些 php 代码(例如登录用户名、用户详细信息)。

我尝试使用 $html = file_get_content("B590.php");

但是 $html 会将 B90.php 的内容作为纯文本(带有 php 代码)。

有什么方法可以在评估后获取文件的内容?似乎有很多相关问题,例如 this onethis one但似乎没有人有任何明确的答案。

最佳答案

您可以使用 include() 来执行 PHP 文件和输出缓冲以捕获其输出:

ob_start();
include('B590.php');
$content = ob_get_clean();

关于php 在获取文件内容之前评估代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13028229/

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