<?php
class ffooo
{
public $arr;
function __construct()
{
$arr=array();
}
function add($val)
{
$arr[]=$val;
}
function get($ind)
{
return $arr[$ind];
}
}
$cont=new ffooo();
$cont->add("derek",'chmo');
echo $cont->get(0);
var_dump($cont);
Can anybody explain me why my array $arr is NULL after method add($val)? I try to echo array $arr in method "add",and in this method $arr contained come value; but in another method it becomed NULL? What is the magic?I do't understand the logic(