So I'm basically trying to create a CRUD class, that, when passed the class name, can figure out the basic CRUD operations on it's own using get_class_vars as well as some other means. However, I cannot figure out how to instantiate a class if you have a variable that holds the class name. I know I could use the eval function, but I'm worried about performance if I do that. Was hoping there was something along the lines of $data = new class($dataClass); that was fairly efficient.
I'm using the latest version of php 4 (yeah....don't ask...want five, but due to circumstances out of my control it ain't gonna happen).
instantiating class question..
Moderator: General Moderators
-
codemonkey46
- Forum Newbie
- Posts: 2
- Joined: Thu Aug 16, 2007 6:23 pm
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Simpler than you think

Code: Select all
$obj = &new $className;-
codemonkey46
- Forum Newbie
- Posts: 2
- Joined: Thu Aug 16, 2007 6:23 pm