What is the exact difference between gettype()
and get_debug_type()
?
Official documentation describes it, but too vague for me:
gettype()
: Get the type or object name of a variableget_debug_type()
: Get the type of a variable
What is the exact difference between gettype()
and get_debug_type()
?
Official documentation describes it, but too vague for me:
gettype()
: Get the type or object name of a variable get_debug_type()
: Get the type of a variable Both functions are generally used for variable debugging and to get the type
of a given variable.
The main difference is:
get_debug_type()
differs fromgettype()
in that it returns type names that are more consistent with actual usage, rather than those present for historical reasons.
gettype()
returns one of the following possible string values:
get_debug_type()
returns one of the following possible string values:
Type + State | Return Value |
---|---|
null | "null" |
Booleans (true or false) | "bool" |
Integers | "int" |
Floats | "float" |
Strings | "string" |
Array | "array" |
Resources | "resource (resourcename)" |
Resources (Closed) | "resource (closed)" |
Objects from Named Classes | The full name of the class including its namespace e.g. Foo\Bar |
Objects from Anonymous Classes | "class@anonymous" |
Sources: