title: PHP - Object of class could not be converted to string
body: <p>I'm trying to print a property of the simple class below. But instead i get the error above. I haven't found an answer on similar questions on here. The error triggers on this line: </p>
  
  <pre><code>echo "$object1 name = " . $object1-&gt;name . "&lt;br&gt;";
  </code></pre>
  
  <p>Using XAMPP on Windows Help?</p>
  
  <pre><code>&lt;?php
      $object1 = new User("Pickle", "YouGotIt");  
      print_r($object1);
      $object1-&gt;name  = "Alice";
  
      echo "$object1 name = " . $object1-&gt;name . "&lt;br&gt;"; /* this triggers the error */
  
      class User
      {
          public $name, $password;
  
          function __construct($n, $p) { // class constructor
              $name = $n;
              $password = $p;
          }
      }
  ?&gt;
  </code></pre>