I want to mix a variable after call a function, but not when I set the variable.
My example code:
<?php $greeting = "hi! {$gbye}"; function greetings() { global $greeting; $gbye = "goodbye!"; return $greeting; } echo greetings(); ?> Fiddle: http://phpfiddle.org/main/code/kd5w-p7q4
I tried escaping the $ symbol: \$, but this only gives me the complete text. And replacing the escaped symbol make the same.
The $gbye variable is inside a language file, by this reason, I have to save the word ($gbye) until I call the function (to replace it as if the full string ($greeting = "hi! {$gbye}";) was inside the function). It's just an example.
So what can I do?
$greeting = "hi! ".$gbye;will work just fine as long as the variable is in scope