View Single Post

  #2 (permalink)  
Old 11-27-2006
Jerry Stuckle
 
Posts: n/a
Default Re: php 5 classes: public, protected and private

jopperdepopper wrote:
> Hi,
>
> finally giving php 5 a go, and going over the new approach to classes.
> Can someone clarify the public, private and protected to me?
>
> I quote the php manual: "The visibility of a property or method can be
> defined by prefixing the declaration with the keywords: public,
> protected or private. Public declared items can be accessed
> everywhere."
>
> But should I read "...can be accessed everywhere within a given class."
> or "...can be accessed by all other classes." ?
>
> Job
>


Job,

You should read "can be accessed everywhere".

Private members can be accessed by members of the class only.
Protected members can be accessed by members of the class or a derived
class.
Public members can be accessed by anyone, including other classes,
functions and any other code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote