PHP-Newbie Posted April 3, 2013 Share Posted April 3, 2013 Hi guys, I started learning PHP for 3-4 months already and just learned the basics so I still have more to learn. I came across frameworks just recently specifically CI. I was thinking the best way to learn PHP would be to analyse frameworks so I want to learn how CI does this: $this->load->view("html") : Parent -> PHP file (not sure) -> method() Would anyone care to explain how does it work. I would appreciate even just a simple detail from other sources, just give me a place to begin with understanding the logic. Right now, I'm learning a lot of stuffs from CI and I'm thankful for those people who are making it. It's a powerful framework. Thank You. Quote Link to comment https://forums.phpfreaks.com/topic/276466-about-codeigniter-logic/ Share on other sites More sharing options...
Solution trq Posted April 3, 2013 Solution Share Posted April 3, 2013 Please, don't like at CI for coding tips, it's not the best designed framework around. You might also want to post an actual example of the code you want to understand. What you have posted is not valid php. Are you referring to this part alone? $this->load->view("html") That is pretty straight forward. $this->load is an object, and the code calls the view() method on that object passing it the string 'html'. Keep in mind that view() may indeed not exist, and this code may actually trigger the load objects __call() method instead. What it actually does, I wouldn't know. I wouldn't touch CI with a barge pole. My guess, load is some form of class loader and view() is indeed calling __call() which probably returns a html based view object. When looking at code like this and trying to figure out what it does its a good idea to follow the code. You know that $this refers to the current object so start there. Can you find a property called $view. Where is it defined and what is assigned to it? Once you know that, you can look at the class that this object refers to and try and locate the view() method. If that method does not exist, look for the magic __call method instead. See here: http://www.php.net/manual/en/language.oop5.overloading.php#object.call to understand what __call does. Quote Link to comment https://forums.phpfreaks.com/topic/276466-about-codeigniter-logic/#findComment-1422604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.