<?php class factory($className){ static function getInstance($className){ if(file_exists('./lib'.$className.".class.php")){ $obj=new $className(); return $obj; } else { return false; } } } }