Welcome Guest, Not a member yet? Register   Sign In
Accessing a User Object From a Parent Controller
#6

[eluser]jonez[/eluser]
If you do not want an outside function call to see it define it as protected. If you are only using it to store data for internal use it doesn't need to be public. It can be but it's better security to use protected.

If you aren't assigning a value in construct you would set it to an empty array or object depending on what you plan on doing with it. Or in your case you'd assign it to the a function call and that function's return value would set it's type.

Code:
class Admin_Controller extends CI_Controller {
protected $data;
protected $user_data;

public function __construct( ) {
  parent::__construct( );

  $this->data = array( ); //array
  $this->user_data = new stdClass( ); //object
}
}


Messages In This Thread
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 11:35 AM
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 11:58 AM
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 12:01 PM
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 12:07 PM
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 12:11 PM
Accessing a User Object From a Parent Controller - by El Forum - 02-02-2014, 12:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB