I was just wondering if anyone knew why I can't use require_once
as a callback for array_walk
. I can just include it in an anonymous function and run that, but it gives an invalid callback error for the usage:
$includes = array(
'file1.php',
'file2.php',
'file3.php'
);
array_walk($includes, 'require_once');
You are going to waste more time finding out what's wrong. Just use:
$includes = [
'file1.php',
'file2.php',
'file3.php'
];
foreach($includes as $include) {
require_once($include);
}
require_once
is not a PHP function, but a control structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With