newbie question |
[eluser]global_erp_solution[/eluser]
I'm a newcomer to codeigniter and somehow I find this one statement very puzzling: $this->load->view(blah); that "load" really puzzles me. What is that? I searched everywhere, but no definition is written anywhere, or did I miss it? as a matter of fact, I can't seem to find "view" also. nothing in the CI_Controller class. Thanks
[eluser]LuckyFella73[/eluser]
Have a look at the user guide in general - very helpful. Regarding your post have a look at this page: http://ellislab.com/codeigniter/user-gui...oader.html
[eluser]global_erp_solution[/eluser]
thanks for the quick reply. I've read the link before, but still unable to understand the true nature of "load". is it a variable? if so, I don't see it declared anywhere. not in CI_Controller nor in Loader class. the closest I can guess is it's an instance of Loader class, therefore it can invoke view() method in Loader class. but then that means CI_Controller must have a reference of an instance of Loader class, which I couldn't find. can you explain this? thanks
[eluser]LuckyFella73[/eluser]
Look at core/Controller.php line 49 ( CI 2.0.2 ) and core/Common.php
[eluser]global_erp_solution[/eluser]
sorry guys, still not getting it. In my mind, I'm expecting a declaration like Code: public $load; and couldn't find that declaration in Loader, Controller or Common. My background is java, so i my mind the code above is the way to declare instance variable. or do you guys do instance variable declaration differently in PHP? thanks
[eluser]LuckyFella73[/eluser]
In Controller.php you have Code: $this->load =& load_class('Loader', 'core'); Where "load_class" is a function declared in Common.php Was it that what you meant?
[eluser]InsiteFX[/eluser]
See as LuckyFella73 showed you ./system/core/Controller.php Code: // See how it is assigning the Loader Class instance to $this->load Now view ./system/core/Loader.php and all of it's methods/functions
[eluser]global_erp_solution[/eluser]
yes, I saw that assignment part. I understood that part. In my understanding (at least in java, .Net, C++, VB and any other language I've used), before assigning to a variable, you need to declare it first. Do you mean we can declare and assign at the same time in PHP? I was hoping for something like this: Code: //first the declaration while in Controller, I only see the assignment part. the declaration part is nowhere to be found. So, no need for declaration in PHP? just assign something and it's declared automatically? thans
[eluser]LuckyFella73[/eluser]
You don't have to (must) declare class variables / properties. But usually it's bad coding style - I don't know the reason "$this->load" isn't declared - I guess there is a reason (better ask oop pros). Bear in mind that all class properties that are not declared are public automatically! See this page: http://php.net/manual/en/language.oop5.properties.php |
Welcome Guest, Not a member yet? Register Sign In |