PHP is_string() Function
is_string()This function is used to detect whether a variable is a string.
PHP Version Requirements: PHP 4, PHP 5, PHP 7
Syntax
bool is_string ( mixed $var )
Parameter Description:
- $var: The variable to be tested.
Return Value
Returns TRUE if the specified variable is a string, otherwise returns FALSE.
Example
Example
if (is_string("2663"))
echo 'This is a string.' . PHP_EOL;
else
echo 'This is not a string.';
var_dump(is_string('XYZ'));
var_dump(is_string("99"));
var_dump(is_string(123.05));
var_dump(is_string(false));
The output result is:
这是一个字符串。 bool(true) bool(true) bool(false) bool(false)Other Extensions
PHP Available Functions