I just spent some time tryin to figure this out and found out how, so thought i would share.
(hope this is the right section for this.)

$content = ob_get_clean();

then insert where ever you want it to show up.

<?php echo $content;?>

Hope this helps someone save some time.

Thanks for sharing.....

and you can also expand the above codes to make a cache file of the index.php above.

Using the same concept, we can make a cache of the index.php above . Create a new directory called cache. make sure this is writtable for the script.

Say, we have a page called entry.php page. add this code in the middle where you want the index.php to appear.


## you must define how many seconds you want the cache to last..
$cachetime = 10080 * 60; 
$cachefile = "cache/index.html";

if(file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile)))  {

   ## the page has been cached from an earlier request

   ## output the contents of the cache file


      ## this will create cache html page of the index.php

    include ('index.php');

    $cachefile = "cache/index.html";

  ## open the cache file "cache/index.html" for writing
   $fp = fopen($cachefile, 'w');

  ##save the contents of output buffer to the file

  fwrite($fp, ob_get_contents());
  ## close the file


  ## Send the output to the browser


That will create a templating system cache like function of the index.php , which is proven to speed up the page load. Ideal if the content does not change a lot..

Coool :)

@TKO You could have added to code snippets.

urtrivedi, yes i seen that after i posted. will do in the future.
Thank you