Executing PHP code in a database
| From: | Leo Spalteholz | Date: | Sat, 08 Mar 2003 05:15:28 +0000 |
| Subject: | Executing PHP code in a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138720@lists.php.net to get a copy of this message | ||
Hi,
I have a table that stores all the "boxes" that my website will
display on the sides. So far the content is simply stored in a text
field and then substituted for the box body. However this way I
can't have any php code in the boxes... What I thought I could do is
have another field that will contain any php code that I want for
that box and then execute that after I read it from the database.
So I have two questions basically.
1. How would I go about executing php code in a string?
Say I have $code = "md5('blah');" how would I execute the code in
the string?
2. If I instead include a file would it have access tio the local
variables?
Ie. In a class I have this:
$strContent = "blah, this is the content I got from the database";
include("includefilefromdatabase.php");
Is the $strContent variable then available from the include file?
Thanks,
Leo