Jump to content

[SOLVED] PHP Classes? Public, Private, Protected functions? ::?


Dale_G

Recommended Posts

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!

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.