RE: [PHP] Making php execute php
| From: | scott [gts] | Date: | Wed, 18 Jul 2001 15:21:17 +0000 |
| Subject: | RE: [PHP] Making php execute php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58452@lists.php.net to get a copy of this message | ||
It's failing becuase $abc is not valid PHP code, but is HTML.
to get eval to work correctly, only pass it valid PHP code.
This will print "Hello World";
$abc = '
print "$Message";
';
$Message="Hello World" ;
eval ($abc) ;
If you want to output HTML, enclose it within
a print "" statement, or something similar.
> -----Original Message-----
> From: Gord Gray [mailto:gord@icu.on.ca]
> Sent: Wednesday, July 18, 2001 10:32 AM
> To: php-general@lists.php.net
> Subject: [PHP] Making php execute php
>
>
> I would like to store a mix of php and html in a database and then return
> the results. I can't figure out how to do this.
>
> $abc='<div class="bob"><?php echo "$Message" ;
> ?></div>' ;
> ...
> $Message="Hello World" ;
> ...
> echo eval ($abc) ;
>
> where $abc is actually retrieved from a database.
> Does not work, but may illustrate what I am trying to accompish. If anyone
> has any hints on how I can do this, I would be very grateful.
>
> Thanks,
>
> Gord.
>
>
>
> --
> 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
>