$string = get_include_contents('somefile.php');
function get_include_contents($filename) {
if (is_file($filename)) {
ob_start();
include $filename;
return ob_get_clean();
}
return false;
}
https://www.php.net/manual/en/function.include.php
有没有一种方法可以从字符串中加载内容而不是从文件中“包含”它们?
我的意思是像这样:
$string = file_get_contents("file.php");
include_from_string($string);