Why is it necessary to define variables inside class?
Here are two classes which do the same thing.
class number_1{
# the variable is defined
var $something;
function something(){
$this->something='Hello<br />';
echo $this->something;
}
}
$print = new number_1;
$print->something();
#############
class number_2{
# the variable isn't defined
function something(){
$this->something='Hello';
echo $this->something;
}
}
$print2 = new number_2;
$print2->something();
The result is: