Hello all, I was wondering why I am getting an error when calling the $this-> method in my class, here is what I mean:
When I run the code I get this:
Why cant I call $this in my method?
Thanks,
timgerr
-How important does a person have to be before they are considered assassinated instead of just murdered?
So there you go! You're the retarded offspring of five monkeys having butt sex with a fish-squirrel! Congratulations!
Code:
class tree {
function recurse($obj)
{
foreach($obj as $key=>$val){
if(is_object($val)){
$this -> recurse($val);
} else {
echo $key . ":" . $val;
}
}
}
}
$p = new stdClass;
$c1 = new stdClass;
$c11 = new stdClass;
$c1->name = 'Michelle';
$c11->name = 'Abby';
$p->name = 'Dan';
$p->child = $c1;
$c1->child = $c11;
tree::recurse($p);
Code:
name:Dan
Fatal error: Using $this when not in object context in C:\xampp\htdocs\mptt\AddObject.php on line 7
Why cant I call $this in my method?
Thanks,
timgerr
-How important does a person have to be before they are considered assassinated instead of just murdered?
So there you go! You're the retarded offspring of five monkeys having butt sex with a fish-squirrel! Congratulations!