3v4l.org

run code in 300+ PHP versions simultaneously
<?php //return $this->has_many('Post'); class Foo{ public static $has_manyhg = "Post"; public static $age = "18"; private static $city = "Boston"; public $r=9; public static $has_many = "Post"; public function has_many($a){ return 'hola'; } function get_relationship($val) { $class = new ReflectionClass('Foo'); $staticProperties = $class->getStaticProperties(); $object=new Foo; $model = ucwords(substr($val, 4)); foreach ($staticProperties as $propertyName => $value) { if(preg_match('/^(has_many|age)$/', $propertyName) && $value == $model) { return $object->{$propertyName}($model); } } } } $foo = new Foo; echo $foo->get_relationship('get_post'); ?>
Output for git.master, git.master_jit, rfc.property-hooks
hola

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