title: Calling protected variable from parent class with getters in php
body: <p>I'm a newbie in OOP in PHP. I have the following problem:
  I have 1 parent class called 'User' and 2 subclasses 'Business' and 'Standaard'.</p>
  
  <p>My parent class looks something like this:</p>
  
  <pre><code>class User {    
  protected $m_iId;
  protected $m_iFoto;
  protected $m_sEmail;
  
  /*Constructor*/
  public function __construct(){
      $this-&gt;Id = -1;
      $this-&gt;Foto = "";
      $this-&gt;Email = "";
  } 
  
  /*Setter*/                    
  public function __set($p_sProperty, $p_sValue){
      switch($p_sProperty){
          case "Id":
              if(is_numeric($p_sValue) &amp;&amp; $p_sValue !== -1){
                  $iNumber = intVal($p_sValue);
                  if($iNumber &gt;= -1){
                      $this-&gt;m_iId = $p_sValue;
                  }
                  else{
                      echo("Not a valid id: ".$p_sValue);
                  }
              }
              break;
          case "Foto":
              if(is_numeric($p_sValue) &amp;&amp; $p_sValue !== -1){
                  $iNumber = intVal($p_sValue);
                  if($iNumber &gt;= -1){
                      $this-&gt;m_iFoto = $p_sValue;
                  }
                  else{
                      echo("Not a valid Foto_id: ".$p_sValue);
                  }
              }
              break;
          case "Email":
              $this-&gt;m_sEmail = $p_sValue;
              break;  
          default: echo("Unknown property: ".$p_sProperty);
      }
  }
  
  /*Getter*/
  public function __get($p_sProperty){
      $vResult = null;
      switch($p_sProperty){
          case "Id";
              $vResult = $this-&gt;m_iId; 
              break;
          case "Foto";
              $vResult = $this-&gt;m_iFoto; 
              break;
          case "Email";
              $vResult = $this-&gt;m_sEmail; 
              break;
          default: echo("Unknown property: ".$p_sProperty);
      }
      return $vResult;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>A child child looks likes this:</p>
  
  <pre><code>class UserStandaard extends User {
  
      //velden die bereikbaar zijn
      protected $m_sName;
  
      /*Constructor*/
      public function __construct(){
          parent::__construct();
          $this-&gt;Name = "";
      } 
  
      /*Setter*/                    
      public function __set($p_sProperty, $p_sValue){
          switch($p_sProperty){
              case "Name":
                  $this-&gt;m_sName = $p_sValue;
                  break;
              default: echo("Unknown property: ".$p_sProperty);
          }
      }
  
      /*Getter*/
      public function __get($p_sProperty){
          $vResult = null;
          switch($p_sProperty){
              case "Name";
                  $vResult = $this-&gt;m_sName; 
                  break;
              default: echo("Unknown property: ".$p_sProperty);
          }
          return $vResult;
          }
  }
  </code></pre>
  
  <p>My question is the following:
  How can I request the Id?
  I want to do something like:</p>
  
  <pre><code>$oUser = new UserStandaard();
  echo $oUser-&gt;Id;
  </code></pre>
  
  <p>But that doesn't work... It keeps echoing </p>
  
  <pre><code>Unknown property: Id
  </code></pre>
  
  <p>Thanks!!</p>