3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeHelperClass { // Version 1 public static function getProperty1(object $object, string $property) { return Closure::bind( function () use ($property) { return $this->$property; }, $object, $object )(); } // Version 2 public static function getProperty2(object $object, string $property) { return ( function () use ($property) { return $this->$property; } )->bindTo( $object, $object )->__invoke(); } } class Test { private $property = 'test1'; private $property2 = 'test2'; } $object = new Test; echo SomeHelperClass::getProperty1($object, 'property'); echo SomeHelperClass::getProperty2($object, 'property2');
Output for git.master, git.master_jit, rfc.property-hooks
test1test2

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:
76.66 ms | 405 KiB | 5 Q