Log in

View Full Version : how to include classes and objects dynamically in php



priya.mehta111
04-25-2010, 11:22 AM
Hello, Can any one tell me the concept of including classes and instance/ objects dynamically.

katierosy
04-27-2010, 01:26 PM
A. If you wanted to know about php serialisation/unserialisation to save objects in databases and use them dynamically,please read more about it.

B. If you wanted to know about including classes and auto loading them, please read about these methods.

a. spl_autoload_register('autoloading method name',false);

b. function __autoload($class) {
if(is_file($class . '.php')){
require_once $class.'.php';
}else{
printf("Error when trying to load %s", $class);
}
}

$okObj = new okClass();