get_debug_type
Returns the type name of a value the way it is written in code.
Syntax
get_debug_type(mixed $value): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | Any value. |
Return value
stringThe name of the type or class.
Examples
Compared with gettype():
<?php
echo gettype(1.5), ' / ', get_debug_type(1.5), "\n";
echo gettype(null), ' / ', get_debug_type(null), "\n";
echo gettype(new ArrayObject()), ' / ', get_debug_type(new ArrayObject());Output:
double / float
NULL / null
object / ArrayObjectNotes
The function is handy for error messages: it returns int, float, null and the class name rather than integer, double, NULL, object.
See also
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.