We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


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.