Variables variable and inheritance

Posted by Xack on Stack Overflow See other posts from Stack Overflow or by Xack
Published on 2012-02-25T17:56:32Z Indexed on 2012/07/03 9:16 UTC
Read the original article Hit count: 199

Filed under:
|
|

I made code like this:

class Object {
    function __get($name){
        if(isset($this->{$name})){
            return $this->{$name};
        } else {
            return null;
        }
    }

    function __set($name, $value){
        $this->{$name} = $value;
    }
}

If I extend this class (I don't want to repeat this code every time), it says "Undefined variable". Is there any way to do it?

© Stack Overflow or respective owner

Related posts about php

Related posts about variables