开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜