Posted By

manteca on 12/29/09


autoload codeigniter

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Codeigniter Autoload Model and Controlle

 / Published in: PHP


Agregar este codigo al final de system/application/config/config.php

Entocnes en lugar de

Class Test extends Model --> Class Test

y en lugar de $this->load->model('test'); $this->test->some_function();

es $var = new Test; $var->some_function();

Esto permite utilizar las funciones de autocompletado de las IDE de desarrollo

  1. function __autoload($class) {
  2. if (file_exists(APPPATH."models/".strtolower($class).EXT)) {
  3. include_once(APPPATH."models/".strtolower($class).EXT);
  4. } else if (file_exists(APPPATH."controllers/".strtolower($class).EXT)) {
  5. include_once(APPPATH."controllers/".strtolower($class).EXT);
  6. }
  7. }

Report this snippet  

You need to login to post a comment.