Public variable used in views can do or not? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Public variable used in views can do or not? (/showthread.php?tid=651) |
Public variable used in views can do or not? - Wong - 01-01-2015 HAPPY NEW YEAR 2015 For User class as :- PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); For User view as:- PHP Code: ... for above example I have declare $tableData is public variable then in view <?php echo $this->tableData; ?> this is good or not ? or I should pass data array via load view RE: Public variable used in views can do or not? - RobertSF - 01-01-2015 Happy 2015 to you too! Think of your situation in terms of coupling. If the data for your view can only come from $this->tableData, your view will be tightly coupled to your class. That means your view will rely on your class to supply the data. That could be ok, unless you can imagine a situation where the data could come from a different source. In that case, it would be better to pass the data via an array. RE: Public variable used in views can do or not? - Wong - 01-01-2015 RobertSF : Thank you |