title: php the point for __get() and __set() magic
body: <p>PHP 5 introduces the magic method __get() and __set().  From my understanding it is a shortcut for having to write each member's getter and setter;</p>
  
  <pre><code> &lt;?php
  class Person {
      private $firstname;
      private $lastname;
  
      function __set($var, $name) {
          $this-&gt;$var = $name;
      }
  
      function __get($var) {
          return $this-&gt;$var;
      }
  }
  
  $person = new Person();
  $person-&gt;firstname = "Tom";
  $person-&gt;lastname = "Brady";
  
  
  echo $person-&gt;firstname . " " . $person-&gt;lastname;
  
  // print: Tom Brady
  ?&gt;
  </code></pre>
  
  <p>My question is, this is just like making the member variables public.</p>
  
  <pre><code>class Person {
      public $firstname;
      public $lastname;
  }
  </code></pre>
  
  <p>Isn't this against OOP principles? And what's the point?</p>