Re: OOP::problem?
| From: | Bertrand Mansion | Date: | Tue, 01 Apr 2003 16:21:01 +0000 |
| Subject: | Re: OOP::problem? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4573@lists.php.net to get a copy of this message | ||
<matthias.nothhaft@gmx.de> wrote :
> Hi all,
>
> this is my first mail to this list,
> but I don't know if this is the right one
> for my problem, because it is not really depending
> on pear, but I hope there are some php devs, who
> can help me?
>
> Ok, I have a little idea to use it in PEAR...
> I promise I'll tell it in my next posting ;-)
>
>
> Take a look at my example:
>
> <?php
>
> class a
> {
> function test($s)
> {
> $this->myvar = $s;
> }
> }
>
> class b
> {
> var $myvar;
>
> function b($s)
> {
> a::test($s);
>
> echo $this->myvar;
> }
> }
>
> $b =& new b("hello world!");
>
> ?>
>
> The output is... "hello world!"
>
> Now my "problem": Is this a bug or a feature,
> that I can access to class variables of any object
> by using $this->anyvar in a class::function() ?
I think it should be considered as a bug, not a feature so don't rely on it..
You might get some better (or more confuse) advices in the php-dev archives..
Bertrand Mansion
Mamasam