dosyaları taramak için PHP.scandir () kullanarak ve sonra onlara Require_once

0 Cevap php

hi again every one this is my third question so far on stackoverflow :D

i am defining files and their location on my first_run.php files, the files that i define here is those files containing classes, helper functions and any other files required

at early development, this first_run.php contains only a few lines of codes but the line is increasing gradually as i add some new classes or new files to be included

i first_run.php her zaman düzenlemek zorunda değilsin ki ve belirli bir klasör içindeki i grup dosyanın konumunu beri, ben, belki ben require_oncenin, klasörü taramak bir diziye alınan dosyaların adını koymak ve daha sonra döngü olduğunu anlamaya i klasörünün içine yeni bir dosya eklemek.

Benim fisrt yaklaşım scandir () kullanarak bir

önce:

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');

sonra şöyle bir şey:

$member_files = scandir(MEMBERS);
foreach($member_files as $member_file):
    require_once(MEMBERS.DS.$member_file);
endforeach;

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)

şimdiden teşekkürler

0 Cevap