robos99 Posted June 13, 2006 Share Posted June 13, 2006 I have a template with html and some php variables inside it. This is stored in a database. What I'm trying to do is make it work so that the variables will show up when the template is displayed.I've tried using eval, but I keep getting parse errors because of the slashes in the template. magic_quotes_runtime is off and magic_quotes_gpc is on. When I don't add any additional escaping to the slashes I get the parse errors I would expect. But when I do addslashes I get"Warning: Unexpected character in input: '\' (ASCII=92)"And then I get parse errors from the variables within the html."Parse error: parse error, unexpected $ "I've tried everything and I'm all out of ideas. Quote Link to comment https://forums.phpfreaks.com/topic/11918-templates-slashes-and-eval/ Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 Don't do this (have a template with variables and then use eval). It's more headache than you can imagine. Instead, use placeholders, and then str_replace.[code]$html = '<title>{_TITLE_}</title>';$output = str_replace('{_TITLE_}', $title, $html);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11918-templates-slashes-and-eval/#findComment-45302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.