Archive

Posts Tagged ‘oop’

quick import constructor

May 12th, 2009 No comments

This snipplet shows how to automatic import parameters into a class, restricted to the variables defined in the head of the class.

class Demo
{
  var $a, $b, $c
 
  function Demo($data)
  {
    while(list($key,$value)=each($data)){
      if(isset($this->$key)){
        $this->$key = $value;
      }
    }
  }
}