在 PHP 中,strlen() 函数用于计算字符串的长度
<?php $str = "Hello, World!\nThis is a test."; $length = strlen($str); echo "The length of the string is: " . $length; // 输出:The length of the string is: 23 ?> 在这个例子中,strlen() 函数会返回字符串 “Hello, World!\nThis is a test.” 的长度,即 23 个字符。注意,换行符也被计算在内。