Codeigniter Class Constructor
Codeigniter class constructor : Constructors are special functions which are called when a new object is created.
Syntax : Codeigniter class constructor
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class User extends CI_Controller { public function __construct() { parent::__construct(); // $this->load->helper('url'); // More code goes here... } }
Note parent::__construct(); is required to override the parent class’s constructor.
Advertisements