zarcel
zarcel

Reputation: 1241

How to load classes as methods like in CodeIgniter

I started using Codeigniter few days ago and I am wondering how does it work?

I mean the whole loading classes, ex:

$this->load->model('model_class_file');

and then using it as

$this->model_class_file->method();

How is it called and what else should I know about php?

Upvotes: 0

Views: 40

Answers (1)

Madara's Ghost
Madara's Ghost

Reputation: 175098

Simple $this->load is a property which holds a Loader object, with a method called model() to load model files. The model is then saved onto a private property as an array element.

When accessing $this->whatever_name_you_put, PHP will magically search for that index in the private property, and make it available.

Upvotes: 1

Related Questions