Re: Processing PHP within a string variable
| From: | Toby Butzon | Date: | Wed, 24 Jan 2001 22:20:57 +0000 |
| Subject: | Re: Processing PHP within a string variable | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36504@lists.php.net to get a copy of this message | ||
Hmm... that may work for what you're trying to do and it may
not... if your string contains something like this:
$str = <<<END_STRING
<b>This is some HTML</b><br>
<i>Powered by PHP <?php echo phpversion() ?></i>
END_STRING;
You're going to have a bit of a problem processing that with
eval.
I'm not completely sure on this one, but you might try this:
eval('?>' . $str);
Assuming your string looks like the $str above, the
beginning '?>' should drop eval out of PHP mode, print the
HTML, execute the PHP commands when it goes back into PHP
mode, etc... it should all work that way.
--Toby
----- Original Message -----
From: "Alexander Skwar" <ASkwar@DigitalProjects.com>
To: "Matt" <bean@yaysoft.com>
Cc: <php-general@lists.php.net>
Sent: Wednesday, January 24, 2001 5:02 PM
Subject: Re: [PHP] Processing PHP within a string variable
> So sprach Matt am Wed, Jan 24, 2001 at 03:56:37PM -0600:
> > string is a mixture of PHP code and HTML. I want to be
able to output the
> > string with the PHP code inside the string processed.
Right now the PHP
>
> http://www.php.net/manual/en/function.eval.php
>
> Alexander Skwar
> --
> How to quote: http://learn.to/quote (german)
http://quote.6x.to (english)
> Homepage: http://www.digitalprojects.com |
http://www.iso-top.de
> iso-top.de - Die guenstige Art an Linux Distributionen
zu kommen
> Uptime: 4 hours 59 minutes
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
php-general-help@lists.php.net
> To contact the list administrators, e-mail:
php-list-admin@lists.php.net
>
>