Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active April 1, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/32fec6a87ad9c3d799cd to your computer and use it in GitHub Desktop.
Save kurozumi/32fec6a87ad9c3d799cd to your computer and use it in GitHub Desktop.
【CodeIgniter3】フックを使ってコントローラーを拡張するクラスを複数作成する方法
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CI_Classes
{
private $_include_paths = array();
public function register(array $paths = array())
{
$this->_include_paths = $paths;
spl_autoload_register(array($this, "autoloader"));
}
public function autoloader($class)
{
foreach ($this->_include_paths as $path) {
$filepath = $path . $class . ".php";
if(!class_exists($class, FALSE) AND is_file($filepath)) {
include_once ($filepath);
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment