Reputation: 521
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 ?
Upvotes: 21
Views: 107640
Reputation: 622
Codeigniter v4: If you are adding it inside a controller method then add return as well:
class MYCONTROLLER extends BaseController {
public function one() {
return $this->two('Hello!');
}
public function two($dummy) {
echo $dummy;
}
}
Upvotes: 0
Reputation: 1889
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
Upvotes: 43