OOPBeginner Posted July 17, 2013 Share Posted July 17, 2013 (edited) 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"); } } } ?> Edited July 17, 2013 by OOPBeginner Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.