3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $name; // private variable private $age; //private variable public function __construct() { $this->name = "a"; } } class B extends A { public function display($name, $age) { $this->name2 = $name; // new name2 variable, NOT A's name $this->age2 = $age; // new age2 variable, NOT A's age echo $this->name2." age is ".$this->age2.PHP_EOL; echo $this->name; } } $ob=new B(); $ob->display("xyz", 23);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property B::$name2 is deprecated in /in/NJZU8 on line 15 Deprecated: Creation of dynamic property B::$age2 is deprecated in /in/NJZU8 on line 16 xyz age is 23 Warning: Undefined property: B::$name in /in/NJZU8 on line 18

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:
164.98 ms | 406 KiB | 5 Q