标签:
① 解析if
<?php $str = ‘{if $data===1} 1 {elseif $data===2} 2 {else} 3 {/if}‘; echo $str; $T_P=array( ‘#\{if(.*)\}#‘, ‘#\{(?:else if|elseif)(.*)\}#‘, ‘#\{else\}#‘, ‘#\{/if\}#‘, ); $T_R=array( ‘<?php if (\1){ ?>‘, ‘<?php else if (\1) { ?>‘, ‘<?php else {?>‘, ‘<?php }?>‘, ); echo ‘<hr>‘; echo preg_replace($T_P, $T_R, $str);
待续............
标签:
原文地址:http://www.cnblogs.com/bai-jimmy/p/4309910.html