Source Code:
(back to article)
<?php $x = 1; class MyClass { public $y; public function __construct() { global $x; $this->y = $x + 1; } } $obj = new MyClass(); echo $obj->y; // Outputs 2
Result:
Report an issue