How can I call a function like below:
$display_table="<table><tr><td>FUNCTION_CALL_HERE();</td></tr></table>";
I have tried brackets and all, but the function wont get called...
How should I make this work? (syntax problems I think)
Thanks
asked Nov 19, 2009 at 4:20
user188962
3 Answers 3
is there a reason you cannot use string concatenation? Assuming the output of FUNCTION_CALL_HERE is a string.
$display_table="<table><tr><td>" . FUNCTION_CALL_HERE() . "</td></tr></table>";
answered Nov 19, 2009 at 4:22
barkmadley
5,3371 gold badge31 silver badges31 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
$display_table="<table><tr><td>" . FUNCTION_CALL_HERE() . "</td></tr></table>";
answered Nov 19, 2009 at 4:22
Langdon
20.1k18 gold badges90 silver badges108 bronze badges
Comments
Alternatively:
$display_table="<table><tr><td>{FUNCTION_CALL_HERE()}</td></tr></table>";
Actually should be:
<?php
function asdf() {
return 'this is my string';
}
$f= 'asdf';
echo "Hello {$f()}\n";
?>
answered Nov 19, 2009 at 5:06
leepowers
38.4k24 gold badges103 silver badges132 bronze badges
lang-php