从输出缓冲区包含?

时间:2011-09-29 09:29:19

标签: php include

我有一个动态生成的页面,其中包含一些BBcode。 例如,我有一个名为[PHP]file.php[/PHP] ..

使用ob_start("parser);缓冲输出。是否可以在输出缓冲区中用[PHP]file.php[/PHP]替换include("file.php");

<?php
function parser($buffer){
   //This is where I want 'it to happen'
}

ob_start("parser");
?>
<html>
..........
<body>
Some text<br /><br />
[PHP]file1.php[/PHP]<br /><br />
More text..<br /><br />
[PHP]file2.php[/PHP]

<?php
ob_end_flush();
?>

1 个答案:

答案 0 :(得分:-1)

不确定;通过调用include()替换它将执行file.php并将输出添加到缓冲区。确保在包含之前对文件名进行一些检查,以防止远程脚本注入等!!

相关问题