class MyTest{
public $array1;
public $array2;
public function __construct()
{
$this->$array1 = array();
$this->$array2 = array();
echo "Hello, I'm constructor<br/>";
$this->m1();
}
function m1(){
echo 'inside function';
for($i=0;$i<10;$i++){
$this->$array1[] = $i;
}
echo '<br/>Array 1<br/>';
print_r(array_values($this->$array1));
echo '<br/>Array 2<br/>';
print_r(array_values($this->$array2));
}
}
new MyTest;
This is the output:
Can anybody tell me why this happen :-( ?