php - 如何将 PHP 文件加载到变量中?

标签 php file

我需要将 PHP 文件加载到变量中。像 include();

我已经加载了一个简单的 HTML 文件,如下所示:

$Vdata = file_get_contents("textfile.txt");

但现在我需要加载一个 PHP 文件。

最佳答案

ob_start();
include "yourfile.php";
$myvar = ob_get_clean();

ob_get_clean()

关于php - 如何将 PHP 文件加载到变量中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1272228/

相关文章:

php - Laravel 5.2 的数据库连接设置

php - 无法将整数数据插入MySQL,它插入为0

android - 如何以编程方式(使用 Intent)在 Android 中打开我的文件文件夹?

c++ - 在 C++ 中全局定义结构

带倒计时的php循环

php - 如果条件为真但不是在每一行都为真,如何插入或更新?

PHP选择所有日期在现在之后的地方

python - Python 会在完成写入之前打开文件吗?

c - Windows 上的 c 中的 Popen : Output not being returned?

c - C语言中如何读取除最后一行之外的文件?