class Test {

  function Test() {
    $_this->foo = "bar";
  }

}

$n = new Test;
echo "foo: " . $n->foo."\n";
var_dump($n);

returns :
foo: 
object(test)(0) {
}

So there is no member variable which you meant to be private in the instance $n of 
class Test.
Have fun.

Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
BALANCED SOLUTIONS


----- Original Message ----- 
From: "Nick Winfield" <[EMAIL PROTECTED]>
To: "Andrey Hristov" <[EMAIL PROTECTED]>
Sent: Tuesday, September 25, 2001 5:13 PM
Subject: Re: [PHP] public and private parts in classes ?


> On Tue, 25 Sep 2001, Andrey Hristov wrote:
> 
> > You by yourself showed that you code return:
> > echo "foo: " . $n->foo;
> > // returns 'foo: '
> > but if the code was correct it must return :
> > "foo: bar",  not "foo: "
> 
> Exactly. Thus, it means that by adding the underscore, I had made the
> property private which was the whole point of the exercise. If the
> property had not been private, then yes the script would have had the
> output "foo: bar". See?
> 
> Cheers,
> 
> Nick W..
> -[ [EMAIL PROTECTED] ]-
> 
> :: 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
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to