Bir klasördeki tüm dosyaları gerektiren kolay bir yolu var mı?
teşekkürler
There is no easy way, as in Apache, where you can just ''Include /path/to/dir'', and all the files get included.
Olası bir yolu SPL RecursiveDirectoryIterator kullanmaktır:
function includeDir($path) {
$dir = new RecursiveDirectoryIterator($path);
$iterator = new RecursiveIteratorIterator($dir);
foreach ($iterator as $file) {
$fname = $file->getFilename();
if (preg_match('%\.php$%', $fname) {
include($file->getPathname());
}
}
}
Bu olursa olsun yapısında ne kadar derin $ yolundan, dosyaları biten tüm. Php çeker.
Bu soruyu daha önce yayınlanan Çıkış: http://stackoverflow.com/questions/599670/how-to-include-all-php-files-from-a-directory