Re: [PHP] Question regarding :: syntax
On Mon, 2002-06-03 at 12:06, Jared Boelens wrote: Is there not a way to refer directly to the parent properties? Or do i have to setup a get function for every parent var that I want to access. Tis my understanding that you cannot refer to class properties without an instance of the class. If I were wrong it would make my life much easier, but I don't believe I am. Regards, Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding :: syntax
So am i to understand that i will have to do it in this manner? class A { var $b; A() { } function getB() { return $this-B; } function setB($b) { $this-B = $b; } } class B extends A { B($b) { parent::setB($b); } } $B = new B(); echo $B-getB(); This means writing a get and set function for every property that belongs to the parent. I understand this is how it is done in other languages but the manual is misleading in this case. It explicity says Sometimes it is useful to refer to functions and variables... This lead me to believe that you could directly access VARIABLES as well as functions. I guess i was wrong. Oh well, it just means more typing for me, which means more hours, which means more $. -Jared -Original Message- From: Tobyn Baugher [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 12:30 PM To: php list Subject: Re: [PHP] Question regarding :: syntax On Mon, 2002-06-03 at 12:06, Jared Boelens wrote: Is there not a way to refer directly to the parent properties? Or do i have to setup a get function for every parent var that I want to access. Tis my understanding that you cannot refer to class properties without an instance of the class. If I were wrong it would make my life much easier, but I don't believe I am. Regards, Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding :: syntax
On Mon, 2002-06-03 at 12:45, Jared Boelens wrote: So am i to understand that i will have to do it in this manner? *SNIP* No no no... B extends A, and you have an instance of B. Just do this: class A { var $b; *snip* } class B { function B($b) { $this-b = $b; } } That will work fine. Regards, Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding :: syntax
This may be a dumb question but, how can you be sure that the $this- is referring to the parent classes' property and not the current class. On that note, does it really matter of which one it refers? -Jared -Original Message- From: Tobyn Baugher [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 12:58 PM To: php list Subject: RE: [PHP] Question regarding :: syntax On Mon, 2002-06-03 at 12:45, Jared Boelens wrote: So am i to understand that i will have to do it in this manner? *SNIP* No no no... B extends A, and you have an instance of B. Just do this: class A { var $b; *snip* } class B { function B($b) { $this-b = $b; } } That will work fine. Regards, Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding :: syntax
On Mon, 2002-06-03 at 13:42, Jared Boelens wrote: This may be a dumb question but, how can you be sure that the $this- is referring to the parent classes' property and not the current class. On that note, does it really matter of which one it refers? B inherits $b from A. $this-b and parent-b are the exact same thing. This is why there's no special syntax to access parent-b from PHP. Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding :: syntax
That is exactly what I thought, I was just looking for some reassurance. I have been working with C# lately and the syntax for classes is a lot more explicit. I wanted to make sure I wasn't making a mistake on what PHP implcitly does. Thanks -Jared -Original Message- From: Tobyn Baugher [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 1:58 PM To: php list Subject: RE: [PHP] Question regarding :: syntax On Mon, 2002-06-03 at 13:42, Jared Boelens wrote: This may be a dumb question but, how can you be sure that the $this- is referring to the parent classes' property and not the current class. On that note, does it really matter of which one it refers? B inherits $b from A. $this-b and parent-b are the exact same thing. This is why there's no special syntax to access parent-b from PHP. Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php