Evaluate page & store in variable?
I want to grab a php file, evaluate any php, then store the contents in a variable.
We'll call this.. page.php
<?php
$content = "Hello World.";
?>
<html>
<head>
<title><?php echo $content ?></title>
</he开发者_运维百科ad>
<body>
<?php echo $content ?>
</body>
</html
And I want to put that into a variable by calling a function from another file.
Use ob_start()
before including the file, and ob_get_clean()
after.
PHP can evaluate any string as a PHP code with function eval; http://php.net/manual/en/function.eval.php
精彩评论