I've a script with variables in a class ($slug).
When I run this script, it works, but I get a warning: Warning: Creating default object from empty value. I know, I can hide this warnings in my php.ini, but how can ik fix this warning?
$test = new myclass();
class myclass {
private $order;
public function __construct() {
$this->order = (object) NULL;
}
public function setVars($slug, $number) {
$this -> order -> $slug -> number = $number;
}
public function getVars($slug) {
echo $this -> order -> $slug -> number;
}
}
$test -> setVars($slug="hello", $number=5);
$test -> getVars($slug="hello");