Entry
How can I store PHP code in a database and then run that code from a mysql_query() call?
Jul 2nd, 2000 15:17
Gijsbert te Riet, Todd Hammer, Onno Benschop,
I don't know if you realy want to do this, but here is an example.
You can execute code which is stored within a string by parsing that
string to the function eval(). So if i have a string like this:
<?php
$a=" echo (\"this is an echo function\"); ";
?>
and i want to execute the code within $a, i have to do:
<?php
eval($a);
?>
which prints "this is an echo function".
So, in your case, you can assign your code to a string (like $a) and
just store it in your database like a normal string.
When your retrieve that string, you can parse it to eval() which
executes the code.