Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Use custom function within view/controller/etc

I'm new to CodeIgniter, so this may sound a bit stupid.

But here's what I want :

(I've thought of simply require_onceing the necessary files, or perhaps creating a CI Library, but I'm still not sure)

What's the most CI-friendly and efficient way you would suggest? Ideas?

Upvotes: 0

Views: 69

Answers (1)

Yan Berk
Yan Berk

Reputation: 14428

Use the libraries:

$this->load->library('my_class');
$this->my_class->some_function();

EDIT:

It is not recommended, but if you must use the library in the view, use it like this:

$data['my_class'] =& $this->my_class;
$this->load->view('my_view', $data);  

Upvotes: 3

Related Questions