Re: php 5 classes: public, protected and private
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 10:28:07 -0500
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@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: php 5 classes: public, protected and private
- From: jopperdepopper
- Re: php 5 classes: public, protected and private
- References:
- php 5 classes: public, protected and private
- From: jopperdepopper
- php 5 classes: public, protected and private
- Prev by Date: -forgot- Storing objects in a session PHP 5.2.0
- Next by Date: Re: Search engine friendly URLs
- Previous by thread: php 5 classes: public, protected and private
- Next by thread: Re: php 5 classes: public, protected and private
- Index(es):
Relevant Pages
|