可以在不包括文件的情况下获得文件输出缓冲区


Is is possible to get file output buffer without including the file?

是否可以获取文件输出缓冲区字符串以在后台执行文件,而不是将其包含在内?

现在这是我看到的唯一的方式。请参阅下面的代码;

ob_start();
include($file);
$html = ob_get_contents();
ob_end_clean();

但我有一份我不想包括的文件清单。我只想在后台执行该文件,以获取输出缓冲区字符串。

有人能帮我吗?

谢谢Smac

如果您的文件是php,则需要使用include。对于多个文件,你可以使用这样的功能,我在这里找到

function include_multi($files) {
    $files = func_get_args();
    foreach($files as $file)
        include($file);
}

并称之为

include_multi("one.php", "two.php", ..);

此外,如果您想要纯文件内容(无需执行文件),您可以使用file_get_contents或读取文件