I'm having trouble understanding the keyword 'this' in php. When and where does it need to be used? Why can you not simply use the variable name as you would normally do when not placing a variable inside a class? In the small test case program below I can't even get the 'this' keyword to work.
#!/usr/bin/php5
<?php
class A
{
public $attribute = 'first attribute';
function myFunction()
{
echo "This is my attribute without the keyword this --> $attribute";
echo "This is my attribute with the keyword this --> $this->$attribute";
}
}
$a = new A();
$a->myFunction();
?>