<?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));
preferences:
54.09 ms | 406 KiB | 5 Q