Re: public and private parts in classes ?
| From: | Nick Winfield | Date: | Tue, 25 Sep 2001 13:49:17 +0000 |
| Subject: | Re: public and private parts in classes ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68702@lists.php.net to get a copy of this message | ||
On Tue, 25 Sep 2001, Andrey Hristov wrote:
> > I'm sorry, if this is a faq. But I would like to know, if there exist
> > public and private parts in classes like in c++ ?
> >
> > AFAIK there are no public and private parts supportet.
> >
> > I would be pleased to get either a confirmation on that or, if it works,
> > some information on how to do it.
> >
> PHP Classes are not so powerful as C++. No there is no division ot
> private and public or protected. All is public but good technique
> is to name methods you prefer to be private with a underbar at the start.
The same applies to properties:
class Test {
function Test() {
$_this->foo = "bar";
}
}
$n = new Test;
echo "foo: " . $n->foo;
// returns 'foo: '
Cheers,
Nick W..
-[ pioneer@dac.org ]-
:: today's word is..
haggis (n): a small, hairy creature that has 8 long legs, looks like a set
of bagpipes and tastes good with deep-fried chipped potatoes