I am trying to further my understanding of classes and how to access variables within methods.
Is it possible to use a variable defined in a method without activating the method it is contained within.
For example in the code below I want to just print the value of the variable $this->a but not perform the method (ie not have '$a + mon' printed out)
<?php
class testclass{
var $a;
function atest(){
$this->a= "si";
echo $this->a."mon";
}
}
$object1 = new testclass;
$object1->atest();
?>
This prints 'simon' but how would I print the value of $a without activating the echo $this->a."mon"; line.
Do I need to put this second line in its own function?