I have saw this answer about require multiple php files, I want to do it use class,like this
class Core
{
function loadClass($files)
{
$this->files = func_get_args();
foreach($files as $file) {
require dirname(__FILE__)."/source/class/$file";
}
}
}
But when I use
$load = new Core;
$load->loadClass('class_template.php');
it doesn't work, can anyone help me to find the error ?
$filesas array and sending it as a string. just add one new line under loadClass file.if(!is_array($files)){ $files = array($files)}or when you are calling your files pass it in array like.$load->loadClass(['class_template.php'])PSR0orPSR4auto loading of classes.