As the title say's i need an critic opinion on the code i did, as i m learning all by my "self" sometimes i miss some feedback on what is best to do or not, so if anyone could throw a couple of tips or warnings please fell free to. This is the code i have:
if( !defined('COREPATH') ) die('Accessing this file directly is not allowed'); defined( 'PS' ) or define( 'PS', PATH_SEPARATOR ); class autoloader{ private $_includePath = null; public function __construct() { $this->_includePath = get_include_path(); } public function register(){ spl_autoload_register( array( __CLASS__, 'loadClass' ) ); } public function unregister(){ spl_autoload_unregister( array( __CLASS__, 'loadClass' ) ); } public function addClassPath( $path ){ $this->_includePath .= PS . $path; } private function setIncludePaths(){ set_include_path( $this->_includePath ); } public function loadClass( $name ){ if( $this->_includePath != get_include_path() ){ $this->setIncludePaths(); } include $name.'.php'; } } $autoloader = new autoloader(); $autoloader->register(); $autoloader->addClassPath( CORECLASSES ); $madb = new database();
Thank you in advance.