is_string
Checks whether a value is a string.
Syntax
is_string(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The value to check. |
Return value
bool`true` if the value is a string.
Examples
A string and a number:
<?php
var_dump(is_string('42'));
var_dump(is_string(42));Output:
bool(true)
bool(false)Notes
A string holding a number is still a string. To find out whether it looks like a number, use is_numeric().
See also
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.