3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait tSB_FormFieldObject { } interface iSB_FormFieldObject { } class SB_FormFieldObject implements iSB_FormFieldObject { use tSB_FormFieldObject; public $Test2 = "aa"; } function test($a=null) { echo "trait: " .($a instanceof tSB_FormFieldObject) . PHP_EOL; echo "interface: " .($a instanceof iSB_FormFieldObject) . PHP_EOL; echo "using: " .(is_using($a, "tSB_FormFieldObject")) . PHP_EOL; echo "instanceof: " .(is_instance_of($a, SB_FormFieldObject)) . PHP_EOL; } function is_using($class, $trait) { return in_array($trait, (new ReflectionClass($class))->getTraitNames()); } function is_instance_of($sub, $super) { $sub = (string)$sub; $super = is_object($super) ? get_class($super) : (string)$super; switch(true) { case $sub === $super; // well ... conformity case is_subclass_of($sub, $super): case in_array($super, class_implements($sub)): return true; default: return false; } } $a = new SB_FormFieldObject(); test($a); ?>
Output for git.master_jit, git.master, rfc.property-hooks
trait: interface: 1 using: 1 Fatal error: Uncaught Error: Undefined constant "SB_FormFieldObject" in /in/8B5rB:15 Stack trace: #0 /in/8B5rB(35): test(Object(SB_FormFieldObject)) #1 {main} thrown in /in/8B5rB on line 15
Process exited with code 255.

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