In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (John A. Grant) wrote:
> I tried this code: > <?php > function somefunc($text,$n) > { > for($i=0;$i<$n;$i++){ > echo $text; > } > } > $string='xxx <?php somefunc("yyy",3); ?> zzz'; > eval($string); > ?> > > but I get > "Parse error: parse error in eval.php(11) : eval()'d code on line 1 eval() treats the passed argument as if it were inline PHP code. You're effectively doing this: <?php function somefunc($text,$n) { for($i=0;$i<$n;$i++){ echo $text; } } xxx <?php somefunc("yyy",3); ?> zzz ?> So the extra set of PHP tags is a problem, and xxx and zzz must both be valid code (i.e. terminating statements with semi-colons, concatenating strings with a period...) I'm guessing what you really want is: eval('somefunc("yyy",3);') In that case, you could use a regex to extract the portion of your text string that's enclosed by PHP tags. -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]