Forum Moderators: coopster

Message Too Old, No Replies

Variable function parsing into string

It works not properly

         

ilin

5:44 am on Oct 17, 2008 (gmt 0)

10+ Year Member



//Variable function
$func = 'foo';

//Functions and method calls inside {$} work since PHP 5
echo "text1 {$func(44)} text2";

function foo($id)
{
echo "foo($id)";
}

output:
foo(44)text1 text2

The result of function parsed.
But result was parsed BEFORE any text.
How can I parse function BETWEEN text blocks?

cameraman

7:09 am on Oct 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World, ilin.

Inneresting, didn't know you could do that.
Change foo to:
function foo($id)
{
return "foo($id)";
}

ilin

7:37 am on Oct 17, 2008 (gmt 0)

10+ Year Member



cameraman, thank You very much!
It works right.