OOPBeginner Posted July 17, 2013 Share Posted July 17, 2013 I have three files index.php, loader.php and BasePresenter.php. In directory Templates / layouts I have 2 file, index.php and header.php like a template files. How Can I automaticaly loaded these files with autoload function from BasePresenter? Thx index.php <?php // index.php // loader require_once 'loader.php'; new BasePresenter(); ?> loader.php <?php // [ LIBS ] // notORM require_once 'libs/NotORM.php'; // [ MODELS ] // database require_once 'models/db.php'; // [ PRESENTERS ] // base presenter require_once 'presenters/BasePresenter.php'; ?> BasePresenter.php <?php class BasePresenter { public function __construct( ) { function __autoload($class_name) { require_once($class_name.".php"); } } } ?> Link to comment https://forums.phpfreaks.com/topic/280236-how-can-i-use-autoload-for-my-structure-app/ Share on other sites More sharing options...
OOPBeginner Posted July 17, 2013 Author Share Posted July 17, 2013 I know how to do this, sorry ))) thanks Link to comment https://forums.phpfreaks.com/topic/280236-how-can-i-use-autoload-for-my-structure-app/#findComment-1441047 Share on other sites More sharing options...
trq Posted July 17, 2013 Share Posted July 17, 2013 Do yourself a favour and follow a standard. See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md Link to comment https://forums.phpfreaks.com/topic/280236-how-can-i-use-autoload-for-my-structure-app/#findComment-1441076 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.