PHP - Require Dir Files .php


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.