Please have a look at the below example code. From that I have index, test_1 & test_2 functions.
If the index function's case-1 statements executed, I'm getting output 12. But case-2 statement getting the error Message: Call to a member function test_2() on null.
Can anyone help me to make the case-2 statement work?
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Debug extends CI_Controller
{
public function index()
{
//case 1 : Working
$this->test_1();
$this->test_2();
//case 2: Not Working
echo $this->test_1()->test_2();
}
function test_1()
{
echo "1";
}
function test_2()
{
echo "2";
}
} ?>
Thanks in advance..
$this->test1()->test2()to work,test2()would need to be a method oftest1()(which would need to be a class, not a method