5
In the example I have a function named funcao
, which aims only to display the value of the parameter on the screen.
By creating a string
with the function name and call it as a function, it will be executed:
<?php
function funcao($parametro = "default") {
echo $parametro . "<br/>\n" ;
}
$func = "funcao";
$func("kirotawa");
$func = "FUNCAO";
$func();
?>
Because I happen to be able to call the function this way?
Why can you ?
– Diego Souza
That’s the kk question, I think it’s because of the automatic typing of the
php
and calling with()
he interprets that thatstring
is the name of a function so try to call it. But wanted a better explanation.– Leonardo
There’s a duplicate of this. It’s hard to find
– Maniero
@bigown is the same thing as variable variables?
– rray
@rray I don’t know, didn’t I see that? P
– Maniero
Actually, there’s probably a duplicate but I searched and found nothing.
– Leonardo