The following code was found in all the .php files loaded in the specified folder (defined separately). Can it be put in the array to simplify the code?
Only a few variables changes but essentially repeats the code several times.
// Normal Files $ the_general = opendir (FRAMEWORK_GENERAL); While (($ the_general_files = readdir ($ the_general)) == Incorrect) {If (strows ($ the_general_files, '.php')) {include_once (frameworld_general. $ The_general_files); }} Closed ($ the_general); // plugin files $ the_plugins = opendir (framework_plugins); While (($ the_plugins_files = readdir ($ the_plugins))! == Incorrect) {If (stropo ($ the_plugins_files, '.php')) {include_once (FRAMEWORK_PLUGINS. $ The_plugins_files); }} Closed ($ the_plugins); There are several other sections that are called separate folders.
Any help is greatly appreciated.
Cheers, James
I have to use it in a better way . And make it in a function.
Function includes all the directory ($ directory) {if (! Is_dir ($ directory)) {return false; } // Be sure to add a trailing slash $ directory = rtrim ($ directory, '/ \\'). '/'; Foreach (Globe ("{$ directory} * .php") as $ filename} {require_once ($ directory. $ Filename); } Back true; }
Comments
Post a Comment