I have a controller that have about 5-6 functions.
class Register extends CI_Controller {
public function index()
{
// some code written
}
public function Add()
{
// Some code written
}
public function xyz()
{
// Some code written
$this->abc();
}
public function abc()
{
// Some code written
}
}
In xyz
function, i want to call abc
function.
Is this possible ? if so, how to call it ?
class Send_value extends CI_Controller { public function main_page() { $data['user'] = $this->input->post('fullName'); ... } public function welcome_page(){ //Now I would like to pass $data['user'] here. } }
In terms of codeigniter: You'll notice that each controller in codeigniter extends the base controller class. Using $this in a controller gives you access to everything which is defined in your controller, as well as what's inherited from the base controller.
It is possible, the code you have written is correct
public function xyz()
{
// Some code written
$this->abc(); //This will call abc()
}
EDIT:
Have you properly tried this?
class Register extends CI_Controller {
public function xyz()
{
$this->abc();
}
public function abc()
{
echo "I am running!!!";
}
}
and call register/xyz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With