When is __construct called and when is index called? And are there any other differences?
And what to put in __construct? Whats the best practice, should I put $this->load calls... ? what else?
class Site extends CI_Controller {
public function __construct() {
parent::__construct();
echo 'Hello World2';
}
public function index() {
echo 'Hello World1';
}
}
__construct() is called first, then according to URL is called index() or other functions.
public function __construct() should contain:
public function index() should contain:
it is bad design if public function __construct() contain:
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