Re: $this->value VS $value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 23, 2008 at 9:55 AM, uaca man <uacaman@xxxxxxxxx> wrote:

> Hello to all my fellow members of the PHP community.
>
> As a personal rule i always use $this in front of class members, but i
> always knew from others programing languages and i guess I just
> thought it was same in PHP that without $this keyword it should work
> just the same, however in the code bellow it is clear that $value is
> not the same as $this->value. This test was done in PHP5.
>
> Anyone care to elucidate if this is correct?


afaik, php requires instance variables to be qualified w/ $this->, no matter
what.  in other languages, you can omit the this (self or w/e) keyword,
unless you want to settle a collision between a local variable and instance
variable w/ the same identifier.  unfotunately it doesnt work like that in
php, and although it requires more typing, i think it makes the code more
understandable at a glance.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux