<?php
$a = 'ec';
$b = 'ho';
$c = $a.$b;
echo('Huh?');
$c('Hello, PHP!');
?>
yields
Huh?
Fatal error: Call to undefined function echo() in <...>/php.php on line 11
Why?
echo
is technically not a function in PHP. It is a "language construct".
echo('Huh?')
is an alternate syntax for echo 'Huh?'
You can do this instead:
function my_echo($s) {
echo $s;
}
$a = "my_echo";
$a("Huh?");
echo is a language construct and not a function. What you're trying to do will work with actual functions. Something like this will work.
<?php
function myecho($src) { echo $src; }
$a = 'myec';
$b = 'ho';
$c = $a.$b;
$c('This is a test');
?>
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