Question: I am trying to make some cache system for my php engine, so I need to save html source of just rendered php file. 
I know that I could create some $htmlsource var and render all page to it, but there is a lot of work to change for that.
I would like to get just rendered html from some buffer or whatever, can you help me?

Answer: 
You need to use output buffering. 

```
ob_start();
//here is php code prints some content
$content = ob_get_content();

```
This is what output buffering does for you. 

Before you start output any data issue a ob\_start command. and before you are done do $html = ob\_get\_clean(); 

Here is a minimal example of the steps needed to implement a page caching system 

```
$html = get_from_cache($cachekey);
if(!$html){
   ob_start();
   // output your page.
   $html = ob_get_clean();
   update_cache($cachekey, $html);
}
echo $html;

```