PHP Value Inspection Reference
Choose a predicate that answers the exact type or missing-value question. A false-like value is not automatically an invalid value.
How it works
get_debug_type gives a readable diagnostic name. is_int, is_string and related predicates inspect the current type rather than parsing an external representation. isset and empty are language constructs with their own null/truthiness rules. A reference lookup should include the failure result and the accepted argument types, not just the function’s spelling. The related-name index is an API inventory, not a claim that every name is recommended in new code.
Run it locally
Run this complete source locally with PHP 8.2 or newer. Save it using the filename shown and run the command below. PHP is not currently available in Bhylu’s browser playground. Apache and MySQL are not needed for an ordinary CLI example.
php -l ref-values.php
php ref-values.phpDownload this source as a local PHP lab file. Keep lab files separate from the Bhylu project and production data.
Example
<?php
declare(strict_types=1);
$values = [0,"0",null];
foreach ($values as $value) echo get_debug_type($value), ":", is_int($value) ? "integer" : "other", "\n";
Expected result
int:integer
string:other
null:otherThe two zero-like values retain their different types. The null value is deliberately absent data, not a failed integer parse. This diagnostic output helps you select a parser contract but should not be dumped alongside private request/session data in a public response.
Contracts to check
| API or term | Important boundary |
|---|---|
| get_debug_type, gettype | Inspect the current representation; do not treat a diagnostic name as validation. |
| is_int, is_float, is_string, is_bool | Check actual scalar types, not every convertible representation. |
| is_array, is_object, is_iterable, is_countable | Ask distinct container/protocol questions. |
| isset, empty, array_key_exists | Distinguish missing/null/truthiness/key existence. |
| serialize, unserialize | Object serialisation has class-instantiation risks; do not decode untrusted serialised objects. |
| var_export, var_dump, print_r | Diagnostics can expose secrets and private structure. |
Related API names
This alphabetic inventory helps locate related calls. Availability was checked in the review runtime; it is not a recommendation to use every API or a claim that every overload/function was executed. Read the official entry for version, extension, failure and security details.
| Name | Review-runtime status |
|---|---|
boolval() | Available in the PHP review runtime |
debug_zval_dump() | Available in the PHP review runtime |
doubleval() | Available in the PHP review runtime |
empty | Language construct |
floatval() | Available in the PHP review runtime |
get_defined_vars() | Available in the PHP review runtime |
get_resource_type() | Available in the PHP review runtime |
gettype() | Available in the PHP review runtime |
intval() | Available in the PHP review runtime |
is_array() | Available in the PHP review runtime |
is_bool() | Available in the PHP review runtime |
is_callable() | Available in the PHP review runtime |
is_countable() | Available in the PHP review runtime |
is_double() | Available in the PHP review runtime |
is_float() | Available in the PHP review runtime |
is_int() | Available in the PHP review runtime |
is_integer() | Available in the PHP review runtime |
is_iterable() | Available in the PHP review runtime |
is_long() | Available in the PHP review runtime |
is_null() | Available in the PHP review runtime |
is_numeric() | Available in the PHP review runtime |
is_object() | Available in the PHP review runtime |
is_real() | Not available in this review runtime; check version and extension requirements |
is_resource() | Available in the PHP review runtime |
is_scalar() | Available in the PHP review runtime |
is_string() | Available in the PHP review runtime |
isset | Language construct |
print_r() | Available in the PHP review runtime |
serialize() | Available in the PHP review runtime |
settype() | Available in the PHP review runtime |
strval() | Available in the PHP review runtime |
unserialize() | Available in the PHP review runtime |
unset | Language construct |
var_dump() | Available in the PHP review runtime |
var_export() | Available in the PHP review runtime |
Check the official PHP manual for detailed version and API contracts.