简体   繁体   中英

call function in php, little help please

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

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>";
 $display_table="<table><tr><td>" . FUNCTION_CALL_HERE() . "</td></tr></table>";

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";

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM