title: how fix an error Creating default object from empty value
body: <p>I've a script with variables in a class ($slug).</p>
  
  <p>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?</p>
  
  <pre><code>    $test = new myclass();
  class myclass {
      private $order;
  
      public function __construct() {
          $this-&gt;order = (object) NULL;
      }
      public function setVars($slug, $number) {
          $this -&gt; order -&gt; $slug -&gt; number = $number;
      }
  
      public function getVars($slug) {
          echo $this -&gt; order -&gt; $slug -&gt; number;
      }
  }
  $test -&gt; setVars($slug="hello", $number=5);
  $test -&gt; getVars($slug="hello");
  </code></pre>