mannyee Posted August 29, 2010 Share Posted August 29, 2010 hi guys!! after spending few months on oop based programming, i'm trying to structure my code in mvc way... and i found this tutorial at http://www.phpro.org/tutorials/Model-View-Controller-MVC.html by kevin waterson. i can make almost all of it except the code on indexController.php this class has a private variable $registry. the author has assigned it an object that acts like a global variable. when i dump this variable as i get the following: Registry Object ( [vars:Registry:private] => Array ( [db] => PDO Object ( ) [router] => Router Object ( [registry:Router:private] => Registry Object *RECURSION* [path:Router:private] => C:\wamp\www\phpro\phprotest/controller [args:Router:private] => Array ( ) [file] => C:\wamp\www\phpro\phprotest/controller/indexController.php [controller] => index [action] => index ) [template] => Template Object ( [registry:Template:private] => Registry Object *RECURSION* [vars:Template:private] => Array ( [welcome] => Welcome to PHPRO MVC ) ) ) ) and later on the author uses the following code /*** set a template variable ***/ $this->registry->template->welcome = 'Welcome to PHPRO MVC'; to access a property $welcome in the template object. ....... as i understand template is just an array item in the vars[] array which is the private property of registry object (and this object is stored into the $this->registry property).... i don't understand the concept how the array item 'template' that stores the Template class object is used to access the Template class property welcome to set the value.... i mean if(is_object($this->registry->template)) echo 'yes'; prints yes. can someone shed the light on this? Quote Link to comment https://forums.phpfreaks.com/topic/212008-accessing-object-in-arrays/ Share on other sites More sharing options...
mannyee Posted August 31, 2010 Author Share Posted August 31, 2010 finally after a real depth speculation, i now understand this stuff...... nyways thanks to them who cared to read the post Quote Link to comment https://forums.phpfreaks.com/topic/212008-accessing-object-in-arrays/#findComment-1105686 Share on other sites More sharing options...
mayoralito Posted September 10, 2010 Share Posted September 10, 2010 And, the answer? Could you share your answer please? Regards Quote Link to comment https://forums.phpfreaks.com/topic/212008-accessing-object-in-arrays/#findComment-1109728 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.