PHP is_string() 函数

PHP 教程 · 2019-01-31 20:29:06

is_string() 函数用于检测变量是否是字符串。

PHP 版本要求: PHP 4, PHP 5, PHP 7

语法

bool is_string ( mixed $var )

参数说明:

  • $var:要检测的变量。

返回值

如果指定变量为字符串,则返回 TRUE,否则返回 FALSE。

实例

实例

<?php if (is_string("2663")) echo '这是一个字符串。' . PHP_EOL; else echo '这不是一个字符串。'; var_dump(is_string('XYZ')); var_dump(is_string("99")); var_dump(is_string(123.05)); var_dump(is_string(false)); ?>

输出结果为:

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

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

High Performance Python

High Performance Python

Andrew Lewis / O'Reilly Media, Inc. / 2010-09-15 / USD 34.99

Chapter 1. Introduction Section 1.1. The High Performance Buzz-word Chapter 2. The Theory of Computation Section 2.1. Introduction Section 2.2. Problems Section 2.3. Models of Computati......一起来看看 《High Performance Python》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换