title: In PHP, why am I getting the "class name must be a valid object or string" error?
body: <pre><code>    &lt;?php
  class article{
      public $title='';
      public $text='';
      public $instancesFilesmage='';
      public $currentDate='';
      public $section='';
  }
  //Definition of article class
  for($instancesFiles=0;$instancesFiles&lt;count(scandir("Articles/".date('y-m-d').""));$instancesFiles++){
  //For each file inside the directory for today's articles, each of which corresponds to an instance of the "article" class...
          $dir="Articles/".date("y-m-d")."/".($instancesFiles+1)."";
          $artProps=scandir($dir);
      //Retrieve an array of its interior files, each of which corresponds to a property of the aforementioned instance
      for($propertiesFiles=0;$propertiesFiles&lt;count($artProps);$propertiesFiles++){
          //For each item in "artProps", each of which corresponds to a property of the instance
          $instName="".date("y-m-d")."_".($instancesFiles+1)."";
          $$instName=new $article();
          $$instName-&gt;$currentDate=''.time().','.date("y-m-d").'';
          //This just sets defines the time and date at which the article was published, the sole property which exists independently from any file
          if(pathinfo($artProps[$propertiesFiles], PATHINFO_BASENAME)=='TITLE'){
              $$instName-&gt;$title=fgets($artProps[$propertiesFiles]);
          }
          if(pathinfo($artProps[$propertiesFiles], PATHINFO_BASENAME)=='TEXT'){
              $$instName-&gt;$text=fgets($artProps[$propertiesFiles]);
          }
          if(pathinfo($artProps[$propertiesFiles], PATHINFO_BASENAME)=='SECTION'){
              $$instName-&gt;$section=fgets($artProps[$propertiesFiles]);
          }
          //3 ABOVE CONDITIONALS:See if it is one of the properties whose definition is found by retrieving the first line of the file, and, if so, get that first line and set the property to that first line
          if(pathinfo($artProps[$propertiesFiles], PATHINFO_BASENAME)=='IMAGE'){
              $$instName-&gt;$image=$artProps[$propertiesFiles];
          }
          //1 ABOVE CONDITIONAL:See if it is an image, and set the image property of the particular instance to that file
          echo("&lt;p&gt;{$instName-&gt;$title}&lt;p&gt;");  
      }
  }
  </code></pre>
  
  <p>?></p>
  
  <p>I'm getting the "class name must be a valid object or string error" when I first initiate an instance of the "article" class. Why? Does it have to do with me using double variables? How can I get around this?</p>