user188962
user188962

Reputation:

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

Upvotes: 0

Views: 85

Answers (3)

leepowers
leepowers

Reputation: 38318

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

?>

Upvotes: 0

Langdon
Langdon

Reputation: 20073

 $display_table="<table><tr><td>" . FUNCTION_CALL_HERE() . "</td></tr></table>";

Upvotes: 0

barkmadley
barkmadley

Reputation: 5317

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

Upvotes: 2

Related Questions