How to determine whether it is a string in PHP: You can use PHP's built-in function is_string() to determine. The is_string() function is used to detect whether a variable is a string. If the specified variable is a string, it returns true, otherwise it returns false.
php provides us with the is_string() function, which is used to detect whether a variable is a string.
If the specified variable is a string, return TRUE, otherwise return FALSE.
(Recommended video tutorial: php video tutorial)
Grammar:
bool is_string ( mixed $var )
(Recommended related tutorial: php graphic tutorial)
Implementation code:
<?php if (is_string("2663")) echo '这是一个字符串。' . PHP_EOL; else echo '这不是一个字符串。'; var_dump(is_string('XMYZ')); var_dump(is_string("999")); var_dump(is_string(1293.05)); var_dump(is_string(false)); ?>
Run result:
这是一个字符串。 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!