PHP function is_scalar()
Availability in versions: PHP 4.0.5
Checks if the input is a scalar value.
Scalar variables are variables containing integer (integer), float, string or boolean. The array, object and resource types are not scalar.
Note: The value null is not scalar!
Note:
is_scalar() does not consider values of type
resourceto be scalar because it is an abstract data type (which may change over time). This implementation detail should not be relied upon as it may change.
Parameters
| Parameter | Data type | Default value | Note |
|---|---|---|---|
$var |
mixed |
not | Variable to be checked |
Return values
bool
Returns true if the input is scalar. Otherwise false.
Other resources
[Official is-scalar documentation](Official documentation)