Code: Select all
<?php
class myclass {
function myclass($foo, $bar, $baz) {
$this->foo = $foo;
$this->fields = array('id' => $bar, 'name' => $baz);
}
function test($id){
echo $id;
$thisnode = $this->fields->id; // this returns an error
echo $thisnode;
}
}
$test = new myclass('foo','bar', 'baz');
$test->test(3);Code: Select all
3
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs4/testclass.php on line 14So I was hoping to get the result: '3bar'
I have tried any variation, but I'm lost. Any ideas?