3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GrandParentWithConstructor { function __construct() {} } class ParentWithConstructor extends GrandParentWithConstructor { function __construct() {} } class ChildWithoutConstructor extends ParentWithConstructor {} $refl = new ReflectionMethod('ParentWithConstructor', '__construct'); try { $refl->getPrototype(); } catch (\ReflectionException $e) { var_dump(substr(strstr($e->getMessage(), "::__construct", 1), 7)); } $refl = new ReflectionMethod('ChildWithoutConstructor', '__construct'); try { $refl->getPrototype(); } catch (\ReflectionException $e) { var_dump(substr(strstr($e->getMessage(), "::__construct", 1), 7)); }

preferences:
45.42 ms | 2114 KiB | 5 Q