3v4l.org

run code in 300+ PHP versions simultaneously
<?php class B { public $var; protected $var2; protected $_var3; public function __construct($var) { $this->var = $var; $this->var2 = $var; $this->_var3 = $var; } } class A { public $class; public function __construct(B $class) { $this->class = $class; } } $b = new B('test'); $a = new A($b); echo $b->var."\n"; echo $b->var2."\n"; echo $b->_var3."\n"; echo $b->class->var."\n"; echo $a->class->var2."\n"; echo $a->class->_var3."\n"; echo $a->class->var."\n"; $b->var = 'test2'; echo $b->var."\n"; echo $b->var2."\n"; echo $b->_var3."\n"; echo $b->class->var."\n"; echo $a->class->var2."\n"; echo $a->class->_var3."\n";
Output for git.master, git.master_jit, rfc.property-hooks
test Fatal error: Uncaught Error: Cannot access protected property B::$var2 in /in/rWGo7:24 Stack trace: #0 {main} thrown in /in/rWGo7 on line 24
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.16 ms | 401 KiB | 8 Q