Re: Re: $this->value VS $value

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

 



uaca man wrote:
> Yes, it is not the same. Should it be the same?
> 
> 2008/9/23 Nathan Rixham <nrixham@xxxxxxxxx>:
>> uaca man 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?
>>>
>>> Tks,
>>> Ângelo
>>>
>>> class test
>>> {
>>>    private $value;
>>>
>>>    public function    __construct()
>>>    {
>>>        $this->value = "test";
>>>        echo "Not using this:" . $value  . "<br>";
>>>        echo "Using this:" . $this->value . "<br>";
>>>    }
>>> }
>>> new test();
>>>
>>> ?>
>>> output:
>>> Not using this: =
>>> Using this: = test
>> yeah that's right; add in one more line and the reason why is apparent..
>>
>> class test
>> {
>>    private $value;
>>
>>    public function    __construct()
>>    {
>>        $this->value = "test";
>>        $value = 'another test';
>>        echo "Not using this:" . $value  . "<br>";
>>        echo "Using this:" . $this->value . "<br>";
>>    }
>> }
>> new test();
>>
>> ?>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 

No

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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