PHP strlen() 函数

PHP 教程 · 2019-01-30 09:12:20

实例

函数返回字符串 "Hello" 的长度:

<?php
echo strlen("Hello");
?>

定义和用法

strlen() 函数返回字符串的长度。

语法


strlen(string)


参数 描述
string 必需。规定要检查的字符串。

技术细节

返回值: 如果成功则返回字符串的长度,如果字符串为空则返回 0。
PHP 版本: 4+
更新日志: 在 PHP 5.3.0 之前,该函数把数组当做字符串 Array,这样就返回一个长度为 5 的字符串,并产生一个 E_NOTICE 级别的错误。

更多实例

实例 1

返回字符串 "Hello World" 的长度:

<?php
echo strlen("Hello world!");
?>

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

查看所有标签

Algorithms of the Intelligent Web

Algorithms of the Intelligent Web

Haralambos Marmanis、Dmitry Babenko / Manning Publications / 2009-7-8 / GBP 28.99

Web 2.0 applications provide a rich user experience, but the parts you can't see are just as important-and impressive. They use powerful techniques to process information intelligently and offer featu......一起来看看 《Algorithms of the Intelligent Web》 这本书的介绍吧!

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

多种字符组合密码

html转js在线工具
html转js在线工具

html转js在线工具

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

UNIX 时间戳转换