some uncertanties. |
[eluser]timaksu[/eluser]
these questions might be a little too general..but they're used on codeigniter applications and confuse me.. it doesnt hurt to ask right? anyway, i read through this http://www.jimohalloran.com/2007/09/23/b...on-part-2/ (and i can tell it was using an older version of CI) but had a few things i didnt understand. on that page, scroll down to his "FeedItemModel" class. we can see Code: private $_id = false; that isnt within a function. and then within functions, he uses $this->feed_id etc... are the two connected? is he simply defining them vars at the start to later use them in this manner: $this->var_name..? if so, whats the benifit? lastly, and alot less codeigniter like, whats the difference between public and private? both in functions, and those vars that are defined.
[eluser]davidbehler[/eluser]
Try the PHP documentation, that should cover most of your questions regarding OOP! http://www.php.net/manual/en/language.oop5.basic.php
[eluser]Dam1an[/eluser]
The benefit of defining variables in the class is that you can access them within any function in that class As for public vs private: Public: Can be called anywhere within the class, and from any other class Private: Can only be accessed within that class Protected: Can only be used in that class any any class which extends it Hope that clears things up a bit
[eluser]timaksu[/eluser]
[quote author="Dam1an" date="1240679390"]The benefit of defining variables in the class is that you can access them within any function in that class As for public vs private: Public: Can be called anywhere within the class, and from any other class Private: Can only be accessed within that class Protected: Can only be used in that class any any class which extends it Hope that clears things up a bit[/quote] and the value of it is kept between classes or is it reset to whatever it was declared as? also, a part of my question wasnt answered, and i cant 'google' it because i dont know what i should google. thats Quote:and then within functions, he uses $this->feed_id etc… are the two connected? is he simply defining them vars at the start to later use them in this manner: $this->var_name..? if so, whats the benifit? why does he do $this-> ? cant he just access the declared public/private var's by their names? if not, how does other classes access these vars? $classes_name->var_name ? bah 8-/
[eluser]Dam1an[/eluser]
If you declare a class variable and then a variable of the same name within a function, using the variable name will refer to the one in the function, but using $this->var will make it use the class variable |
Welcome Guest, Not a member yet? Register Sign In |