Posted By

jgeewax on 05/23/07


Tagged

get php include contents parsed


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

pablodgavilan
basicmagic
remysharp
vali29
heinz1959
bioascii
emuman
nb109
ringo380


Get Include Contents


 / Published in: PHP
 

This was posted on the PHP website, I use it quite often. You may get a warning as it is an "unsafe" include (include($var)), but it's a risk that needs to be taken.

  1. /**
  2.  * Fetch the files contents -- parsed by PHP -- as if it were included
  3.  *
  4.  * @param string $file
  5.  * @return string
  6.  */
  7. function get_include_contents($file) {
  8. if (!is_file($file) || !file_exists($file) || !is_readable($file)) return false;
  9. include($file);
  10. $contents = ob_get_contents();
  11. return $contents;
  12. }

Report this snippet  

You need to login to post a comment.