3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { public $public = 'Pub'; protected $protected = 'Protec'; private $private = 'Pri'; function printHello() { echo $this->public; echo $this->protected; echo $this->private; } } class MyClass2 extends MyClass { // We can redeclare the public and protected method, but not private function printHello() { echo $this->public; echo $this->protected; echo $this->private; } } $obj2 = new MyClass2(); //echo $obj2->public; // Works //echo $obj2->protected; // Fatal Error //echo $obj2->private; // Undefined $obj2->printHello(); // Shows Public, Protected2, Undefined ?>
Output for git.master, git.master_jit, rfc.property-hooks
PubProtec Warning: Undefined property: MyClass2::$private in /in/eDIbm on line 27

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:
43.27 ms | 401 KiB | 8 Q