Dale_G Posted August 3, 2008 Share Posted August 3, 2008 Hey again! Basically I was wondering about classes in PHP. I've heard about different types of functions, public private and protected and I've noticed in some classes people use '::' alot. So I was just wondering if someone could explain a little bit about classes and such, maybe write a really quick dummy class to help show what each type of function does maybe? But any help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/117953-solved-php-classes-public-private-protected-functions/ Share on other sites More sharing options...
wildteen88 Posted August 3, 2008 Share Posted August 3, 2008 public, private and protected are not functions but called visibility keywords. It allows you to control how items (methods and properties) can used within an object public means an item can be used anywhere private means that an item can used within the class it is defined in, or the class it is inherited from. protected means the item can only be used within the class it is defined in php.net has very good examples of how these are used, here :: is the scope resolution operator, here is an explanation Quote Link to comment https://forums.phpfreaks.com/topic/117953-solved-php-classes-public-private-protected-functions/#findComment-606750 Share on other sites More sharing options...
Dale_G Posted August 3, 2008 Author Share Posted August 3, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/117953-solved-php-classes-public-private-protected-functions/#findComment-606759 Share on other sites More sharing options...
trq Posted August 3, 2008 Share Posted August 3, 2008 Wildteen actually got private and protected mixed up, they ought be the other way around. Quote Link to comment https://forums.phpfreaks.com/topic/117953-solved-php-classes-public-private-protected-functions/#findComment-606778 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.