All pastes #982728 Raw Edit

Anonymous

public php v1 · immutable
·published 2008-04-12 20:31 UTC
rendered paste body
<?phpclass A{    private $a;    protected $b;    public $c;    function __construct($a, $b, $c)    {        $this->a = $a;        $this->b = $b;        $this->c = $c;    }        protected function getVariables()    {        return get_object_vars($this);    }        protected function setVariable($var,$value)    {        $this->$var = $value;    }}class B extends A{        public function __construct(A $objA)    {        foreach($objA->getVariables() as $key => $value)            {                $this->setVariable($key, $value);            }            }        }$obj= new A('pierwsza', 'druga', 'trzecia');$obj = new B($obj);var_dump($obj); // ["a:private"]=>"pierwsza" ["b:protected"]=>"druga" ["c"]=>"trzecia"?>