开发者

preg_replace with php code

I have a function that finds a regex thingy, then replaces with php code. I want to have it replace the found regex with php code on the scre开发者_如何学编程en, like have it echo out ". except when it echos that in the source, it shows all the <?php tags and echo and everything, and doesnt just output 'wat'. no im not going to just replace the text with the word 'wat' because that is not what im trying to do. do you know how to parse the php i replace it with?

$this->template = preg_replace("/<!-- IF (.*?)? ?-->/","<?php\nif($1) {",$this->template);

there is also and ENDIF which closes it with } ?>. the content in between is the output if the condition is true.


Maybe what you need is eval() http://php.net/manual/en/function.eval.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜