function util_include_php_files($dir) { if (!is_dir($dir)) { return; } if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file[0] === '.') { continue; } $path = realpath($dir . '/' . $file); if (is_dir($path)) { util_include_php_files($path); } else { if (substr($file, -4, 4) === '.php') { include_once $path; } } } closedir($dh); } }
<?php /** * @copyright 2005-2008 OpenPNE Project * @license http://www.php.net/license/3_01.txt PHP License 3.01 */ require_once 'OpenPNE/DB.php'; // OpenPNE/db 以下のすべてのPHPファイルを include $dir = dirname(__FILE__) . '/db'; util_include_php_files($dir);