on-internet
← Community

How to load a custom CodeIgniter library then access its instantiated object

Stack Overflow ·

I have a library file named myMenu.php <?php class myMenu { function show_menu() { $obj = & get_instance(); $obj->load->helper('url'); $menu = "<ul>"; $menu .= "<li>"; $menu .= anchor('books/index','List of books'); $menu .= "</li>"; $menu .= "<li>"; $menu .= anchor('books/input', 'Books entry'); $menu .= "</li>"; $menu .= "</ul>"; return $menu; } } Now I loaded this library in my controller books.php function index() { $this->load->library('myMenu'); $menu = new myMenu; $data['menu'] = $menu->show_menu(); $this->load->view('main_view',$data); } But the page shows error: An error occurred : Un

Comments

Sign in or sign up to comment and upvote.

No comments yet.