How to determine whether it is a string in php

藏色散人
Release: 2023-03-04 08:44:01
Original
7982 people have browsed it

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)".

How to determine whether it is a string in php

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

Parameter description:

$var: Variable to be detected.

Return value

If the specified variable is a string, TRUE is returned, otherwise FALSE is returned.

Example

Copy after login

The output result is:

This is a string.

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
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!