I wanted to ask whether I'm doomed to use eval() or there may be a work around.
$str = 'Hello, $user.'; // $str is a string gotten from an external source
// Many lines later
$user = 'John Doe';
echo eval('return "'.$str.'";');
Not a big fan of eval, as probably many of you. Is there another way to parse a PHP string?
eval()maybesprintf()is an option?str_replace('$user', $user, $str)?$user