The difference between mb_ series functions and ordinary character functions
The
mb function is a function extension that processes text according to the encoding format.
Modify the /etc/php.ini configuration file and add extension=php_mbstring.so
Let’s use my most commonly used substr function as an example. It's clear at a glance.
Example:
<span style="color: #008080"> 1</span> <span style="color: #000000">php </span><span style="color: #008080"> 2</span> <span style="color: #008000">//</span><span style="color: #008000">phpinfo();</span> <span style="color: #008080"> 3</span> <span style="color: #800080">$str</span> = 'abcdef'<span style="color: #000000">; </span><span style="color: #008080"> 4</span> <span style="color: #0000ff">echo</span> <span style="color: #008080">strlen</span>(<span style="color: #800080">$str</span>);<span style="color: #008000">//</span><span style="color: #008000"> 6</span> <span style="color: #008080"> 5</span> <span style="color: #0000ff">echo</span> '<br>'<span style="color: #000000">; </span><span style="color: #008080"> 6</span> <span style="color: #0000ff">echo</span> <span style="color: #008080">substr</span>(<span style="color: #800080">$str</span>, 1,2);<span style="color: #008000">//</span><span style="color: #008000"> bc</span> <span style="color: #008080"> 7</span> <span style="color: #0000ff">echo</span> '<br>'<span style="color: #000000">; </span><span style="color: #008080"> 8</span> <span style="color: #008080"> 9</span> <span style="color: #800080">$str2</span> = '我是谁ab'<span style="color: #000000">; </span><span style="color: #008080">10</span> <span style="color: #0000ff">echo</span> <span style="color: #008080">substr</span>(<span style="color: #800080">$str2</span>, 2, 2);<span style="color: #008000">//</span><span style="color: #008000"> ��</span> <span style="color: #008080">11</span> <span style="color: #0000ff">echo</span> '<br>'<span style="color: #000000">; </span><span style="color: #008080">12</span> <span style="color: #0000ff">echo</span> mb_substr(<span style="color: #800080">$str2</span>, 2, 2, 'UTF-8');<span style="color: #008000">//</span><span style="color: #008000"> 谁a</span> <span style="color: #008080">13</span> <span style="color: #0000ff">echo</span> '<br>'<span style="color: #000000">; </span><span style="color: #008080">14</span> <span style="color: #0000ff">echo</span> <span style="color: #008080">strlen</span>(<span style="color: #800080">$str2</span>);<span style="color: #008000">//</span><span style="color: #008000"> 11</span> <span style="color: #008080">15</span> <span style="color: #0000ff">echo</span> '<br>'<span style="color: #000000">; </span><span style="color: #008080">16</span> <span style="color: #0000ff">echo</span> mb_strlen(<span style="color: #800080">$str2</span>, 'UTF-8');<span style="color: #008000">//</span><span style="color: #008000"> 5</span> <span style="color: #008080">17</span> <span style="color: #0000ff">echo</span> '<br>';
Look at lines 10 and 12, the effect is clear.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.