Classes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If a property must be a certain type, yes, I believe it should have a get/set. If the property is a "public" or "protected" one, I generally believe they should have a get/set. If it should be read only, you should only have only a get available for the outside, while authentication should be used on the set method. On private variables, I don't think they are necessary unless there needs to be some form of processing done whenever it's accessed.. This follows the instances I listed previously..
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

feyd wrote:If a property must be a certain type, yes, I believe it should have a get/set. If the property is a "public" or "protected" one, I generally believe they should have a get/set. If it should be read only, you should only have only a get available for the outside, while authentication should be used on the set method. On private variables, I don't think they are necessary unless there needs to be some form of processing done whenever it's accessed.. This follows the instances I listed previously..
.... and if you're running PHP4 it doesn't really make much difference other than the first sentence :P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

true, 5 introduced a lot more support for "standard" OOP support found in many languages, but there is still more work to be done.. 5.1 greatly increased the speed at which PHP could parse and render the code, along with objects, but still has some of the flaws of it's major version (which are being worked on..)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

private variables, from what I can see, may be of use for extending and inheritence overloading..

No idea how though :p
Post Reply