Posted By

nicolaspar on 09/07/07


Tagged

php dir directorio require once incluir


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

basicmagic
hudge
skywalker
MoFu


PHP - Require Dir Files .php


 / Published in: PHP
 

  1. function require_once_dir( $path ){
  2. $dir = dir($path);
  3. while(($file = $dir->read()) !== false)
  4. if( is_file($path .'/'. $file) and preg_match('/^(.+)\.php$/i', $file) )
  5. require_once($path .'/'. $file);
  6. $dir->close();
  7. }
  8. #Example
  9. require_once_dir( 'lib/db' );
  10. require_once_dir( 'lib/email' );

Report this snippet  

You need to login to post a comment.