3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $one = ''; public $two = ''; //Constructor public function __construct() { //Constructor } //print variable one public function echoOne() { echo $this->one."\n"; } //print variable two public function echoTwo() { echo $this->two."\n"; } } //Instantiate the object $a = new A(); //Instantiate the reflection object $reflector = new ReflectionClass('A'); //Now get all the properties from class A in to $properties array $properties = $reflector->getProperties(); $i =1; //Now go through the $properties array and populate each property foreach($properties as $property) { echo $property->getName(); echo "\n\n\n\n\n"; //Populating properties $a->{$property->getName()}=$i; //Invoking the method to print what was populated $a->{"echo".ucfirst($property->getName())}()."\n"; $i++; }
Output for git.master, git.master_jit, rfc.property-hooks
one 1 two 2

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