Array of instances not working...
Posted: Thu Mar 17, 2005 11:08 pm
Code: Select all
Class A{
var $value;
function A($val){
$this->value = $val;
}
function getValue(){
return $this->value;
}
}
Class B{
var $aray = array();
function B(){
$this->aray[] = new A(4);
$this->aray[] = new A(2);
$this->aray[] = new A(7);
}
function getArray(){
return $this->aray;
}
}
$obj = new B();
$myaray = $obj->getArray();
echo $myaray[0]->getValue(); // this will not recognise 'getValue()' as methodThanks in advance...