php 模板替换解决方法

WBOY
Release: 2016-06-13 13:41:20
Original
1164 people have browsed it

php 模板替换
如果 我要将模板文件的{$a}替换成 而不要把其他的{ok}这里面的替换 只替换有变量的 请问这样代码怎么实现? 把变量前面的替换我倒是知道 preg_replace('#{\s*\$#','
------解决方案--------------------

PHP code

$str='{$a}{ok}';
echo preg_replace('#\{(\$\w+)\}#','<?php echo $1;?>',$str); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!