I'm unfamilar with using variable functions in PHP, but I've repeatedly re-read the manual:
and it's not at all clear what I'm doing wrong here:
for ($i = 0; $i < 10000; $i++) {
$Function_Name = 'Test_Function_'.sprintf('%03d', $i);
function $Function_Name() {
echo __FUNCTION__.' is working.';
}
$Function_Name();
}
Why is this loop not creating and running 10000 variable functions?
Alternative using anonymous functions
An alternative approach (using anonymous functions) doesn't seem to work either:
for ($i = 0; $i < 10000; $i++) {
$Function_Name = 'Test_Function_'.sprintf('%03d', $i);
${$Function_Name} = function () {
echo __FUNCTION__.' is working.';
}
${$Function_Name}();
}
eval()-ing10,000 strings.function Function_Name() {$some_function = function() { /* do stuff */ }and then call$some_function();