Dynamic Properties

Dynamic properties are properties created on the fly, without previous definition.

When the class implements the magic methods __get() and __set(), of if the class extends stdclass, then no warning is emitted.

<?php

class X {
    private $property = 1;

    function foo() {
        // dynamic property
        $this->a = 1;

        // dynamic property with variable name
        $b = "abc";
        $this->$b = 1;

        // static property
        $this->property = 1;
    }
}

?>

Documentation

See also PHP, what are dynamic properties?

Related : Properties, Magic Methods, stdclass