can someone pls fill me in on the correct syntax for this in PHP? I have:
function mainFunction($str,$thingToDoInMain){
$thingToDoInMain($str);
}
function printStr($str){
echo $str;
}
mainFunction("Hello",printStr);
I am running this on WAMP and I get an error/warning saying
use of undefined constant printStr - assumed 'printStr' on line 5
...and then I get "Hello" printed out as desired further down the page.
So, how do a refer to the function printStr in the last line to get rid of warning? I have tried $printStr, printStr() and $printStr. Thanks in advance.
Helloas it is, unless you made a typo.thingToDoInMainis not a valid function name. The value of that variable,$thingToDoInMain, is