Сreated客户端模板
<textarea name="template">text {$text} text</textarea>
<?
$template = $_REQUEST['template'];
$text = 'working!';
echo $template; // but displays 'text {$text} text', instead of 'text working! text'
?>
我该如何解决这个问题?
答案 0 :(得分:1)
问题是在你的textarea中,$ text不是变量,而是字符串,因此你必须用str_replace或preg_replace替换它。
试试这个:
<?
$template = $_REQUEST['template'];
$text = 'working!';
$replaced = str_replace('{$text}', $text, $template);
echo $replaced;
?>