views:

281

answers:

1

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 screen, 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.

A: 

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

gX