Re: Parse PHP inside a variable
| From: | Zak Greant | Date: | Thu, 21 Jun 2001 08:13:24 +0000 |
| Subject: | Re: Parse PHP inside a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-54703@lists.php.net to get a copy of this message | ||
Write your code to a temporary file, include the file and then delete it.
<?php
// HTML + PHP mixed code
$code = "<b><?php echo 'BOO!' ?></b>";
// Create a temporary file to store the code
$file = tempnam ('/tmp', 'eval');
error_log ($code, 3, $file);
// include the temp file
include ($file);
// erase the temp file
unlink ($file);
?>
/* Note - I have not tested the above code, however it should work... :) */
Good luck!
--zak
----- Original Message -----
From: "James Atkinson" <james.atkinson@100world.ca>
To: <php-general@lists.php.net>
Sent: Wednesday, June 20, 2001 10:08 PM
Subject: RE: [PHP] Parse PHP inside a variable
> I'm in the same boat, I've tried eval() but it dosan't like mixing PHP and
> HTML code...
>
> I've tried the suggestions listed in the php.net manual too to no avail...
>
> - James
>
>
> > -----Original Message-----
> > From: Lenar Lõhmus [mailto:lenar@dotcom.ee]
> > Sent: June 20, 2001 3:01 PM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] Parse PHP inside a variable
> >
> >
> > maybe function eval()?
> >
> > lenar.
> > "Claus Heiko Niesen" <cniesen@gmx.net> wrote in message
> > news:5.1.0.14.2.20010620165136.00a68728@pop.gmx.net...
> > > Hello
> > >
> > > I'm having a variable that contains HTML with embedded PHP code. When
I
> > > echo it then the PHP code does not get executed. Is there a way I can
> > > parse/print the content of my variable?
> > >
> > > Thanks
> > > Claus
> > >
> > >
> > > --
> > > 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
> > >
> >
> >
> >
> > --
> > 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
>
>
> --
> 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
>