How to determine whether it is a string in php

王林
Release: 2023-03-05 09:14:01
Original
5237 people have browsed it

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.

How to determine whether it is a string in php

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 )
Copy after login

(Recommended related tutorial: php graphic tutorial)

Implementation code:

<?php
if (is_string("2663"))
    echo &#39;这是一个字符串。&#39; . PHP_EOL; else
    echo &#39;这不是一个字符串。&#39;;
var_dump(is_string(&#39;XMYZ&#39;));
var_dump(is_string("999"));
var_dump(is_string(1293.05));
var_dump(is_string(false));
?>
Copy after login

Run result:

这是一个字符串。
bool(true)
bool(true)
bool(false)
bool(false)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!