After a while, I was finally able to pass a pointer to a function like this:
function originalFunction($value) {
print "I am in the function, with value $value";
}
function testFunctionPointer($functionName, $id) {
$functionName($id);
}
$test = testFunctionPointer("originalFunction", 200);
Basically, I realized that if you pass a STRING and you use that string as a function name, the function is executed.
In fact, in the example above, the “originalFunction” is correctly called.
But how can I get the parameter working? It’s always zero…
PS: I know that what I am doing is not clean, it shouldn’t be done, etc. etc. etc. But it’s just for an INTERNAL PROJECT I am doing for MYSELF, so nobody will get hurt by this 😉
Thank you in advance!
Your code is executing well for me, outputting
200as expected.Also you can directly call it like this: