mb函数是根据编码格式 处理文字的函数扩展。
修改/etc/php.ini配置文件,增加extension=php_mbstring.so
用我最常用的substr函数举例子。一目了然。
举例:
<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>';
看第10和12行,作用就很清楚了。

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Adaptateur de serveur SAP NetWeaver pour Eclipse
Intégrez Eclipse au serveur d'applications SAP NetWeaver.

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Listes Sec
SecLists est le compagnon ultime du testeur de sécurité. Il s'agit d'une collection de différents types de listes fréquemment utilisées lors des évaluations de sécurité, le tout en un seul endroit. SecLists contribue à rendre les tests de sécurité plus efficaces et productifs en fournissant facilement toutes les listes dont un testeur de sécurité pourrait avoir besoin. Les types de listes incluent les noms d'utilisateur, les mots de passe, les URL, les charges utiles floues, les modèles de données sensibles, les shells Web, etc. Le testeur peut simplement extraire ce référentiel sur une nouvelle machine de test et il aura accès à tous les types de listes dont il a besoin.

Dreamweaver CS6
Outils de développement Web visuel

MantisBT
Mantis est un outil Web de suivi des défauts facile à déployer, conçu pour faciliter le suivi des défauts des produits. Cela nécessite PHP, MySQL et un serveur Web. Découvrez nos services de démonstration et d'hébergement.