如何将字符串转换为“;双引号”;


How to convert a string to the type of "double quotes"

创建的客户端模板

<textarea name="template">text {$text} text</textarea>
<?
    $template = $_REQUEST['template'];
    $text = 'working!';
    echo $template; // but displays 'text {$text} text', instead of 'text working! text'
?>

我该如何解决这个问题?

问题是,在您的文本区域中,$text不是一个变量,而是一个字符串,因此您必须将其替换为str_replace或preg_replace。

试试这个:

<?
$template = $_REQUEST['template'];
$text = 'working!';
$replaced = str_replace('{$text}', $text, $template);
echo $replaced;
?>