PHP Magic Methods __set and __get
<p>Would doing this be consider good practice...</p>

<p>I have class A with the following definitions:</p>

<pre><code> class A{
      private $_varOne;
      private $_varTwo;
      private $_varThree;
      public $varOne;


      public function __get($name){

   $fn_name = 'get' . $name;

         if (method_exists($this, $fn_name)){
             return $this-&gt;$fn_name();
   }else if(property_exists('DB', $name)){
             return $this-&gt;$name;
   }else{
    return null;
   }
      }

  public function __set($name, $value){

   $fn_name = 'set' . $name;

   if(method_exists($this, $fn_name)){
    $this-&gt;$fn_name($value);
   }else if(property_exists($this-&gt;__get("Classname"), $name)){
    $this-&gt;$name = $value;
   }else{
    return null;
   }

  }

      public function get_varOne(){
           return $this-&gt;_varOne . "+";
      }


 }

 $A = new A();
 $A-&gt;_varOne;     //For some reason I need _varOne to be returned appended with a +

 $A-&gt;_varTwo;     //I just need the value of _varTwo
</code></pre>

<p>In order to not create 4 set and 4 get methods, I have used the magic methods to either call the respected getter for the property I need or just return the value of the property without any change.Could this be consider good practice?</p>
