3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static $has_many = "Post"; public function has_many($a){ return 'hola'; } function get_relationship($model) { $class = new ReflectionClass($this); $staticProperties = $class->getStaticProperties(); foreach($staticProperties as $propertyName => $value) { if(preg_match('/^(has_many|age)$/', $propertyName) && $value == $model) { return $this->{$propertyName}($model); } } } function __get($name, $args) { if(strpos($name, 'get_') === 0) { $model = ucwords(substr($name, 4)); return $this->get_relationship($model); } } } $foo = new Foo; echo $foo->get_post; ?>
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.24
Fatal error: Method Foo::__get() must take exactly 1 argument in /in/NHb2p on line 30
Process exited with code 255.

preferences:
179.17 ms | 1399 KiB | 61 Q