Welcome to WebmasterWorld Guest from 54.197.72.5

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Executing a PHP function in a variable?

     
4:47 pm on Jan 3, 2007 (gmt 0)

New User

5+ Year Member

joined:Jan 1, 2007
posts:24
votes: 0


I have a function,

function output($output) {
echo $output;
}

I have a variable,
$myvar = 'This is my variable. The output is X';

How do I combine the two?

I've tried:

$myvar = 'This is my variable. The output is' . output("this thing");

But no such luck.

5:03 pm on Jan 3, 2007 (gmt 0)

New User

5+ Year Member

joined:Jan 1, 2007
posts:24
votes: 0


Heh, my fault actually.

I guess I should be using "return" instead of "echo" for functions :)

5:08 pm on Jan 3, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 19, 2005
posts:77
votes: 0


Doesn't work for you? That works for me just fine. Does your file have a .php extension or is htaccess to prase the html properly?
4:17 pm on Jan 4, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:298
votes: 0


Echo and Return are extremely different concepts that in certain circumstances can acheive the same result. Read up on the output buffer.