CodeIgniter call function within the same class CodeIgniter call function within the same class codeigniter codeigniter

CodeIgniter call function within the same class


OK, I agree this is a MAJOR goof-up; comes from lack of OOP understanding;

<?phpclass Inventory extends Controller {    function current_stock() {        //do something    }    function add_stock() {        //do something-else        $this->current_stock();        // and we called the other method here!    }}

Just that I didn"t expect it to be so easy


Just use $this->your_function_name();


Only $this->nameFunction();
example

<?php class Hello extends CI_Controller{ public function index(){  $this->hello(); }public function hello(){  return "hello world"; }}