Let's talk about two methods:
1) define a string variable to save the list of files to be loaded. Then foreach loads.
Copy codeThe Code is as follows:
$ A = '/a. class. php;/Util/B. class. php;/Util/c. class. php ';
$ B = '/d. php;/e. class. php;/f. class. php;/g. class. php ';
// Load basic system files
$ Kernel_require_files = explode (';', $ a); // SYS_REQUIRE_LIB_FILE_LIST );
Foreach ($ kernel_require_files as $ f ){
Require_once (SYS_LIB_PATH. '/System'. $ f );
}
// Load basic system files
$ Kernel_require_files = explode (';', $ B); // SYS_BASE_FILE_LIST );
Foreach ($ kernel_require_files as $ f ){
Require_once (KERNEL_PATH. $ f );
}
2) load all the files to be loaded in an include file, and include the include file directly on the current page.
Include. php file content
Copy codeThe Code is as follows:
Require_once ('func. php ');
Require_once ('langmanager. class. php ');
Require_once ('_ KernelAutoLoader. class. php ');
Require_once ('applicationsettingmanager. class. php ');
Require_once ('lib/System/Activator. class. php ');
Require_once ('lib/System/Util/CXML. class. php ');
Require_once ('lib/System/Util/CWeb. class. php ');
I personally think the second method is more efficient, because there are no redundant foreach operations ~ Everything needs to be demonstrated, so I have verified it. The following two methods are used to randomly load the time consumed for 10 times:
Foreach
0.017754077911377
0.017686128616333
0.017347097396851
0.018272161483765
0.018272161483765
0.018401145935059
0.018187046051025
0.020787000656128
0.018001079559326
0.017963171005249
Include_once ('include. php ');
0.025792121887207
0.024733066558838
0.025041103363037
0.024915933609009
0.024657011032104
0.024134159088135
0.025845050811768
0.024954080581665
0.024757146835327
0.02684497833252
In addition, I tried to load all the files on the current page.
0.022285938262939
0.024394035339355
0.023194074630737
0.023229122161865
0.024644136428833
0.023538112640381
0.024240016937256
0.025094032287598
0.023231029510498
0.02339506149292
The results surprised me! The first method seems to be the slowest, with the least time consumed. Loading multiple files on the current page takes a lot of time ~
Why? Unknown. I hope to give an answer clearly. No matter how many "X plans" are loaded, I will use the first method ~