Home>Article>Backend Development> How to determine whether it is a string in php
In PHP, you can use the "is_string" function to determine whether a variable is a string. It can be understood that this function only detects the type. Even if a variable is empty, as long as it is a string type, it will return true. Its usage syntax is "bool is_string (mixed $var)".
Recommended: "PHP Video Tutorial"
is_string() detects whether the variable is of string type and returns the value Is true or false. It can be understood here that it only detects the type. Even if a variable is empty, it will return true as long as it is a string type.
PHP version requirements: PHP 4, PHP 5, PHP 7
Syntax
bool is_string ( mixed $var )
Parameter description:
$var: Variable to be detected.
Return value
If the specified variable is a string, TRUE is returned, otherwise FALSE is returned.
Example
The output result is:
This is a string.
bool(true) bool(true) bool(false) bool(false)
The above is the detailed content of How to determine whether it is a string in php. For more information, please follow other related articles on the PHP Chinese website!