Pulling class definition from a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Pulling class definition from a database

Post by kettle_drum »

Was just wondering if anybody had any experience in pulling class definitions from a database and then calling them. Would doing an eval() on the result from the database be enough for php to parse the class and allow you to initilize it?

Thanks.
dledmonds
Forum Newbie
Posts: 2
Joined: Wed Jul 21, 2004 10:40 am

Post by dledmonds »

<?
eval( 'class testing { function testing() {} function hello() { echo( ''hello'' ); } }' );
$testing = new testing();
$testing->hello();
?>

worked fine when I tested it :)
Post Reply