3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserDefinedClass{} class DynamicObject{} $ud_obj = new UserDefinedClass(); $do_obj = new DynamicObject(); $sc_obj = new stdClass(); $a_obj = (object)array(); echo "===[get_class()]===\n"; printf( "UserDefinedClass Object Class: %s\n", get_class($ud_obj)); printf( "DynamicObject Object Class: %s\n", get_class($do_obj)); printf( "StdClass Object Class: %s\n", get_class($sc_obj)); printf( "Array-derived Object Class: %s\n", get_class($a_obj)); echo "\n===[gettype()]===\n"; printf( "UserDefinedClass Object Type: %s\n", gettype($ud_obj)); printf( "DynamicObject Object Type: %s\n", gettype($do_obj)); printf( "StdClass Object Type: %s\n", gettype($sc_obj)); printf( "Array-derived Object Type: %s\n", gettype($a_obj)); echo "\n===[is_a(stdClass::class)]===\n"; printf( "UserDefinedClass Object Type: %s\n", is_a($ud_obj,stdClass::class)); printf( "DynamicObject Object Type: %s\n", is_a($do_obj,stdClass::class)); printf( "StdClass Object Type: %s\n", is_a($sc_obj,stdClass::class)); printf( "Array-derived Object Type: %s\n", is_a($a_obj,stdClass::class)); echo "\n===[instanceof stdClass]===\n"; printf( "UserDefinedClass Object Type: %s\n", $ud_obj instanceof stdClass); printf( "DynamicObject Object Type: %s\n", $do_obj instanceof stdClass); printf( "StdClass Object Type: %s\n", $sc_obj instanceof stdClass); printf( "Array-derived Object Type: %s\n", $a_obj instanceof stdClass); echo "\n===[is_a(DynamicObject::class)]===\n"; printf( "UserDefinedClass Object Type: %s\n", is_a($ud_obj,DynamicObject::class)); printf( "DynamicObject Object Type: %s\n", is_a($do_obj,DynamicObject::class)); printf( "DynamicObject Object Type: %s\n", is_a($sc_obj,DynamicObject::class)); printf( "Array-derived Object Type: %s\n", is_a($a_obj,DynamicObject::class)); echo "\n===[instanceof DynamicObject]===\n"; printf( "UserDefinedClass Object Type: %s\n", $ud_obj instanceof DynamicObject); printf( "DynamicObject Object Type: %s\n", $do_obj instanceof DynamicObject); printf( "DynamicObject Object Type: %s\n", $sc_obj instanceof DynamicObject); printf( "Array-derived Object Type: %s\n", $a_obj instanceof DynamicObject); echo "\n===[is_subclass_of(stdClass::class)]===\n"; printf( "UserDefinedClass Object Type: %s\n", is_subclass_of($ud_obj,stdClass::class)); printf( "DynamicObject Object Type: %s\n", is_subclass_of($do_obj,stdClass::class)); printf( "StdClass Object Type: %s\n", is_subclass_of($sc_obj,stdClass::class)); printf( "Array-derived Object Type: %s\n", is_subclass_of($a_obj,stdClass::class));
Output for 8.0.10
===[get_class()]=== UserDefinedClass Object Class: UserDefinedClass DynamicObject Object Class: DynamicObject StdClass Object Class: stdClass Array-derived Object Class: stdClass ===[gettype()]=== UserDefinedClass Object Type: object DynamicObject Object Type: object StdClass Object Type: object Array-derived Object Type: object ===[is_a(stdClass::class)]=== UserDefinedClass Object Type: DynamicObject Object Type: StdClass Object Type: 1 Array-derived Object Type: 1 ===[instanceof stdClass]=== UserDefinedClass Object Type: DynamicObject Object Type: StdClass Object Type: 1 Array-derived Object Type: 1 ===[is_a(DynamicObject::class)]=== UserDefinedClass Object Type: DynamicObject Object Type: 1 DynamicObject Object Type: Array-derived Object Type: ===[instanceof DynamicObject]=== UserDefinedClass Object Type: DynamicObject Object Type: 1 DynamicObject Object Type: Array-derived Object Type: ===[is_subclass_of(stdClass::class)]=== UserDefinedClass Object Type: DynamicObject Object Type: StdClass Object Type: Array-derived Object Type:

preferences:
33.73 ms | 458 KiB | 5 Q