views:

42

answers:

1
+2  Q: 

save page in php

Hi all, I am writing a web program using mvc php framework. I have index and another view which I want to render the view inside of my index. First I call view then I call index and put view into it. My problem is I want to save the whole view into a variable and do something like echo $view in my index. both require_once and include_once will show my view instantly. I want to save the page with it's variables. Any idea?

+3  A: 

Use output buffering functions. For example:

ob_start();

include('some_page.php');
doSomeOtherStuff();

$contents = ob_get_clean();

$contents will now contain the contents of the page without actually outputting anything to the browser. You can then echo the contents where you see fit.

Tatu Ulmanen
thank u so much. It worked ;)
Ali Bozorgkhan