Very quick n00b question, in PHP can I include a directory of scripts.
i.e. Instead of:
include('classes/Class1.php');
include('classes/Class2.php');
is there something like:
include('classes/*');
Couldn't seem to find a good way of including a collection of about 10 sub-classes for a particular class.
Here is the way I include lots of classes from several folders in PHP 5. This will only work if you have classes though.
If there are NO dependencies between files... here is a recursive function to include_once ALL php files in ALL subdirs:
I suggest you use a readdir() function and then loop and include the files (see the 1st example on that page).
I realize this is an older post BUT... DON'T INCLUDE YOUR CLASSES... instead use __autoload
Then whenever you call a new class that hasn't been included yet php will auto fire __autoload and include it for you
You can use set_include_path:
http://php.net/manual/en/function.set-include-path.php
If your looking to include a bunch of classes without having to define each class at once you can use:
This way you can just define the class on the php file containing the class and not a whole list of
$thisclass = new thisclass();
As for how well it handles all the files? I'm not sure there might be a slight speed decrease with this.