views:

26

answers:

2

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>
</head>
<body>
<?php echo $content ?>
</body>
</html

And I want to put that into a variable by calling a function from another file.

+1  A: 

Use ob_start() before including the file, and ob_get_clean() after.

Ignacio Vazquez-Abrams
Thank you! Works fantastically!
Luke Burns
A: 

PHP can evaluate any string as a PHP code with function eval; http://php.net/manual/en/function.eval.php

aromawebdesign.com