using PHP.scandir() to scan files and then require_once them

impamsacelp

New Member
hi again every onethis is my third question so far on stackoverflow :Di am defining files and their location on my first_run.php files,the files that i define here is those files containing classes, helper functionsand any other files requiredat early development, this first_run.php contains only a few lines of codesbut the line is increasing gradually as i add some new classes or new files to be includedand since i group the file's location inside a particular folder, i figure that maybe i can scan the folder, put the name of the files retrieved into an array and then loop the require_once, so that i dont have to edit first_run.php every time i add a new file inside the folder.my fisrt approach is using scandir()before:\[code\]defined('INC_PATH') ? null : define('INC_PATH', SITE_ROOT.DS.'includes');defined('MEMBERS') ? null : define('MEMBERS', INC_PATH.DS.'models'.DS.'members');require_once(MEMBERS.DS.'member.php');require_once(MEMBERS.DS.'phone.php');require_once(MEMBERS.DS.'profile.php');require_once(MEMBERS.DS.'talent.php');require_once(MEMBERS.DS.'profile_picture.php');require_once(MEMBERS.DS.'audio.php');require_once(MEMBERS.DS.'video.php');require_once(MEMBERS.DS.'gallery.php');require_once(MEMBERS.DS.'statistik.php');require_once(MEMBERS.DS.'inbox.php');require_once(MEMBERS.DS.'comment.php');require_once(MEMBERS.DS.'picked_stat.php');require_once(MEMBERS.DS.'log.php');\[/code\]after is something like:\[code\]$member_files = scandir(MEMBERS);foreach($member_files as $member_file): require_once(MEMBERS.DS.$member_file);endforeach;\[/code\]i havent try the 'after' code though.is this possible?? or is there any other approach?? or should i just leave it that way (keep adding the lines without scanning the files)thanks in advance
 
Back
Top