#1
  1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221

    Why can't we assign properties in Codeigniters construct?


    Why can't we assign properties in Codeigniters construct?

    PHP Code:
    public function __construct()
            {
                
    parent::__construct();
                
    $this->login_library->is_logged();
                
    $this->data['timezones'] = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
            } 

    Can't access $timezones in views. But if I do
    PHP Code:
    public function index()
            {
                
    parent::__construct();
                
    $this->login_library->is_logged();
                
    $this->data['timezones'] = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
            } 
    Then I can.

    How come and what's the logic behind it?
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,273
    Rep Power
    4193
    I'd guess that code igniter overwrites the data property at some point after the constructor is executed. You'd have to start digging around in the code igniters source code to know for sure.
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo