include from output buffer?
I have a dynamically generated page with some BBcode on.
For example I have one named [PHP]file.php[/PHP]
..
The output is buffered using ob_start("parser);
. Is it possible to replace [PH开发者_JAVA百科P]file.php[/PHP]
with include("file.php");
on the output buffer?
<?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();
?>
Sure; replacing it with a call to include()
will execute file.php
and add the output to the buffer. Make sure to do some checks on the filename before including it, to prevent remote script injection etc!!
精彩评论