开发者

Evaluate page & store in variable?

开发者 https://www.devze.com 2022-12-20 14:38 出处:网络
I want to grab a php file, evaluate any php, then store the contents in a variable. We\'ll call this.. page.php

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

精彩评论

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