html - Make a New Variable From String In PHP -


i have script in php this:

echo "the results $res";

and now, want make new variable save script. can do? because value of $res changing depending on input entered user.

if i've understood correctly, want save script variable (let's call $script), when $res="foo", result of echo $script; "the result foo" , when $res="bar", echo $script; returns "the result bar".

i don't think can using normal variable, function:

//the function function get_res($res){     return "the result $res"; }  //the function call $res = "foo"; print get_res($res); $res = "bar"; print get_res($res); 

this output "the result foo" first time function called, , "the result bar" second time.


Comments