Pass Data From One Function To Another In Same Codeigniter Controller

Pass Data From One Function To Another In Same Codeigniter Controller


A controller often comprises of several functions and often the module’s logic demands passing data between the various functions of the Controller. This is a common enough scenario in many Codeigniter projects. In this tutorial, I will demonstrate how you could pass data between two functions within the same Controller in CodeIgniter. In addition, I will show this data in the View.

pass data between functions in CodeIgniter
Here is what the Model looks like:

Model

The Controller is as follows:

Controller

The following View shows the data that has been passed between the functions of the Controller.

View

Conclusion

In this tutorial, I have discussed how to pass data from one function to another in a Controller. You could easily extend this idea within your Codeigniter projects. If you need help, do leave a comment below.

Comments