Tuesday, May 15, 2012

[php] Auto include .php files

Below code to enable auto include for php files. Change the zinclude.php to your current php file name.

$incPath=str_replace("zinclude.php", "", __FILE__);
foreach (glob($incPath."*.php") as $filename){
  $filename=str_replace($incPath, "", $filename);
  //echo$filename."
";//enable for debuging
  if($filename<>"zinclude.php"){
    require_once $filename;
  }
}