<?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, 8.1.23 - 8.1.31, 8.2.10 - 8.2.26, 8.3.0 - 8.3.4, 8.3.6 - 8.3.15, 8.4.1 - 8.4.2
- ===[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:
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
===[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:
67.57 ms | 413 KiB | 5 Q