$this->value VS $value
| From: | uaca man | Date: | Tue, 23 Sep 2008 15:55:10 +0000 |
| Subject: | $this->value VS $value | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-280785@lists.php.net to get a copy of this message | ||
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