Re: [PHP4BETA] Variables (static, reference)
| From: | Sterling Hughes | Date: | Sun, 19 Mar 2000 17:58:00 +0000 |
| Subject: | Re: [PHP4BETA] Variables (static, reference) | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12409@lists.php.net to get a copy of this message | ||
"Rasmus K. Brosboel" wrote:
>
> Hi,
>
> Is it possible to have static variables in classes? I would like a variable
> that is shared between multiple instances of the class.
>
> Also, is it possible to have two variables 'point' to the same object?
>
> If I do:
> $a = new Object()
> $b = $a;
>
> $a is copied into $b. When I change a value in object $a, it is not changed in
> object $b. Do PHP3/4 have the equivalent of C pointers or reference variables?
>
> Thanks in advance,
> -Rasmus K. Brosboel.
PHP4 has references, the correct way to do your example above is:
$a = new Object;
$b = &$a;
This makes $b an alias for $a and modifying $b will modify $a.
Sterling Hughes
sterling@designmultimedia.com