search
HomeheadlinesPHP string function (1): length calculation

* 1.strlen($str)

* 2.mb_strlen($str, $encoding)

$siteName = 'php中文网';

//Get the internal character encoding set

$encoding =   mb_internal_encoding();
echo &#39;内部字符编码集: &#39;,$encoding,&#39;<br>&#39;;

/ /1.strlen($str): Get the string length represented by bytes

//In utf8 mode, a Chinese character is represented by three bytes

echo strlen($siteName),&#39;<br>&#39;;

//2.mb_strlen ($str, $encoding): Get the length represented by the number of characters

echo mb_strlen($siteName, $encoding),&#39;<br>&#39;;

//Omit the second parameter, the system default character encoding set will be used, which is currently utf-8

echo mb_strlen($siteName),&#39;<br>&#39;;  //返回值不变
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)