note 99173 added to language.oop5.autoload
| From: | fka at fatihkadirakin dot com | Date: | Sun, 01 Aug 2010 01:16:34 +0000 |
| Subject: | note 99173 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171290@lists.php.net to get a copy of this message | ||
Or you can use this, without using any "require/include":
<?php
class autoloader {
public static $loader;
public static function init()
{
if (self::$loader == NULL)
self::$loader = new self();
return self::$loader;
}
public function __construct()
{
spl_autoload_register(array($this,'model'));
spl_autoload_register(array($this,'helper'));
spl_autoload_register(array($this,'controller'));
spl_autoload_register(array($this,'library'));
}
public function library($class)
{
set_include_path(get_include_path().PATH_SEPARATOR.'/lib/');
spl_autoload_extensions('.library.php');
spl_autoload($class);
}
public function controller($class)
{
$class = preg_replace('/_controller$/ui','',$class);
set_include_path(get_include_path().PATH_SEPARATOR.'/controller/');
spl_autoload_extensions('.controller.php');
spl_autoload($class);
}
public function model($class)
{
$class = preg_replace('/_model$/ui','',$class);
set_include_path(get_include_path().PATH_SEPARATOR.'/model/');
spl_autoload_extensions('.model.php');
spl_autoload($class);
}
public function helper($class)
{
$class = preg_replace('/_helper$/ui','',$class);
set_include_path(get_include_path().PATH_SEPARATOR.'/helper/');
spl_autoload_extensions('.helper.php');
spl_autoload($class);
}
}
//call
autoloader::init();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 217.131.101.164 (proxied: 99.222.20.31)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/99173
Del: integrated -- https://master.php.net/note/delete/99173/integrated
Del: useless -- https://master.php.net/note/delete/99173/useless
Del: bad code -- https://master.php.net/note/delete/99173/bad+code
Del: spam -- https://master.php.net/note/delete/99173/spam
Del: non-english -- https://master.php.net/note/delete/99173/non-english
Del: in docs -- https://master.php.net/note/delete/99173/in+docs
Del: other reasons-- https://master.php.net/note/delete/99173
Reject -- https://master.php.net/note/reject/99173
Search -- https://master.php.net/manage/user-notes.php