tags:

views:

54

answers:

3

Hi...

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

+2  A: 

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

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

?>
pygorex1
Sorry, no this does not work. The braces can only contain a $ variable reference such as multiply dimensioned arrays.
Don
My first example wasn't quite right - but it is possible to call functions from within strings.
pygorex1