title: Protected functions in PHP
body: <p>This may seem pretty simple and I am sure it is, I am just not getting it.</p>
  
  <p>I understand that protected properties in a class in PHP can only be accessed within the class itself and inherited classes.  Here is my code so far:</p>
  
  <pre><code>class q {
  
      public $publicQ = "This is a public property";
      protected $protectedQ = "This is a proected property";
  
      public function displayProtected() {
  
          echo $this-&gt;protectedQ;
  
      }
  
  }
  
  $q = new q;
  echo $q-&gt;publicQ; #prints "This is a public property"
  echo $q-&gt;protectedQ; #nothing
  $q-&gt;displayProtected();
  </code></pre>
  
  <p>I have read the documentation, looked at other answers on SO and the concept just is not clicking with me.  What do protected properties actually do, why would we use them and why is my example not working?</p>