Welcome Guest, Not a member yet? Register   Sign In
use of $this
#1

Is it ok to assign data into $data in a Controller using $this in order to make it accessablethrough any method in any "child" controller
Code:
class MY_Controller extends CI_Controller
{
   protected $data = array();
   function __construct()
   {
       parent::__construct();

       $this->data['brand'] = 'myCompany';
.....
And now,  another Controller extends MY_controller. It has a method that loads a view and passes $data to this view, like this:
Code:
$this->load->view('start.php', $this->data);
It's works and it is handy, but is it OK, is it good practice?
Reply


Messages In This Thread
use of $this - by muuucho - 12-02-2016, 05:16 AM
RE: use of $this - by Narf - 12-02-2016, 08:40 AM
RE: use of $this - by 040mag - 12-03-2016, 03:23 AM
RE: use of $this - by Narf - 12-03-2016, 08:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB