大家好 :
        我用fck编辑器生产一段html代码如:
       尊敬的{{email}}您好!
       Thank you for visiting 51customimprint, We have successful change your password .
       这个是个字符串 我现在想将里面的{{email}}替换成{$email}
        但是替换成功之后总是输出
      尊敬的{$email}您好!
       Thank you for visiting 51customimprint, We have successful change your password .
不知道该如何处理 请大家多多指教 万分感谢!

解决方案 »

  1.   

    不是替换面 {$email}是 $mail 这个值替换 {email} 这个东西
      

  2.   

    {<? echo $email ?>}
      

  3.   

    <?php
    $email='[email protected]';
    $username='yourname';$str = '尊敬的{{username}},您好!Thank you for visiting 51customimprint, We have successful changed your password  and sent to {{email}}.';$reg_str = preg_replace("/\{\{(.+?)\}\}/e","\${'\$1'}",$str);
    echo $reg_str;
    ?>
      

  4.   

    <?php
    $email='[email protected]';
    $username='yourname';$str = '尊敬的{{username}}您好!Thank you for visiting 51customimprint, We have successful changed your password  and sent to {{email}}.';//這樣也行,更容易理解
    $reg_str = preg_replace("/\{\{(.+?)\}\}/e","\$\$1",$str);
    echo $reg_str;
    ?>
      

  5.   

    从上例
    $reg_str = preg_replace("/\{{2}(\w+)\}{2}/e","$$1",$str);