title: Catchable fatal error: Object of class Author could not be converted to string
body: <p>I'm learning OOP. I have a database class, Author class and a question class. What I want is to put the user input to the appropriate classes, connect to the database and insert the data from the classes.</p>
  
  <pre><code>    // ask.php
  
      $pdo = new DbConnect('host', 'dbname', 'username', 'password');
  
      // Create an Author object
  
      try {
          $author = new Author($first_name, $last_name);
      } catch (Exception $e) {
          echo $e-&gt;getMessage();
      }
  
      // Question object
  
      try {
          $question = new Question($author, $author_question);
      } catch (Exception $e) {
          echo $e-&gt;getMessage(), '&lt;br&gt;';
      }
  
      // Insert the user input into the database
  
      $pdo-&gt;execute_query('INSERT INTO author (first_name, last_name) VALUES (?, ?)', array($author-&gt;getFirstName(), $author-&gt;getLastName()));
      $pdo-&gt;execute_query('INSERT INTO question (author, question) VALUES (?, ?)', array($question-&gt;getAuthor(), $question-&gt;getQuestion()));
      $pdo-&gt;close_connection();
  
      // class.dbconnect.php
  
      public function execute_query($sql, array $data = null)
      {
          $this-&gt;stmt = $this-&gt;conn-&gt;prepare($sql);
  
          if (!$this-&gt;stmt-&gt;execute($data)) {
              throw new Exception('Error with your query.');
          }
      }
  
      // class.question.php
  
      class Question
      {
          private $author;
          private $question;
  
          public function __construct(Author $author, $question)
          {
              $this-&gt;author = $author;
              $this-&gt;question = $question;
          }
  
          public function getAuthor()
          {
              return $this-&gt;author;
          }
  
          public function getQuestion()
          {
              return ucfirst($this-&gt;question);
          }
      }
  </code></pre>