"Stefan Rusterholz" <[EMAIL PROTECTED]> wrote in message
001001c162af$1fd842f0$3c01a8c0@quasimodo">news:001001c162af$1fd842f0$3c01a8c0@quasimodo...
[...]
> As you see, for PHP is some HTML-Code in the php-code-zone. To avoid this,
> do it that way:
> <?php
> function somefunc($text,$n)
> {
> for($i=0;$i<$n;$i++){
> echo $text;
> }
> }
> $string='xxx <?php somefunc("yyy",3); ?> zzz';
> eval("?>$string");
> ?>
>
> Pay attention to the trailing "?>" in eval. That causes php to change to
> HTML-Mode within the eval'd code.
Yes, thanks - it works now. I can see that you have to exit
php code mode before you encounter HTML 'xxx'.
Then you enter php mode, run somefunc() and exit again
so you can deal with HTML 'zzz'. But that leaves you
outside php mode, right? If the next thing after eval()
is more php code, don't you have to enter php mode
again like this:
eval("?>$string<?php ");
echo "hello";
I tried it with and without "<?php" appended to $string. The
"hello" always works. Why? Does eval() automatically put
you back into php mode?
Stated another way, you said that this
$string='xxx <?php somefunc("yyy",3); ?> zzz';
eval("?>$string);
echo "hello";
is equivalent to:
?>xxx <?php somefunc("yyy",3); ?> zzz
echo "hello";
So why doesn't it treat echo "hello" as HTML code in
pass-through mode? In fact, it just prints "hello".
--
John A. Grant * I speak only for myself * (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here
--
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]