[eluser]marty123[/eluser]
Hi, I'm trying to implement my own library, there is an constructor like this one:
Code:
class Menu {
function Menu()
{
$CI =& get_instance();
}
fucntion get_menu ($param){
$CI ->load->model('m_menu');
};
function three(){
...
}
But when I try to use $CI in functions, there is an error :
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: CI
Filename: libraries/menu.php
Line Number: 29
I call my library this way:
Code:
$this->load->library('menu');
$menu1 = new Menu();
$error['menu'] = $menu1->get_menu('PL');
the solution is to add $CI =& get_instance();
in all functions in the class, but I thought it should take $CI from constructor, am I wrong?