This works the same as declaring a normal variable:
$foo = 'bar';
class Foo {
function __construct() {
$this->foo = 'bar';
}
}
PHP classes are not quite the same as in other languages, where member variables must be specified as part of the class declaration. PHP class members can be created at any time.
, public $foo = null; , , .