title: Php Magic Method __get __set - how to set boundaries on specific fields but not others
body: <p>I have a class of entirely private variables; only certain variables will need some data validation on the way in.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>public class Example 
  {
      //**** Variables / Properties ****/
      private $one;
      private $two; 
      private $three;
  
      //**** getter **** // 
      public function __get( $property ) 
      {
          if(property_exists($this,$property) { 
               return $this-&gt;$property;
          }
      }
  
      // **** setter **** //
      public function __set($property, $value) 
      {
           if(property_exists($this,$property)) {
              $this-&gt;$property = $value;
           }
      }
  }
  </code></pre>
  
  <p>What if I want to do data validation on $two but just return $one and $three without any data validation?<br>
  I ask this because my class has many more variables than this and I hate writing individual set and get methods for every property of the class when only some of them require specific behavior.</p>