"mbstring" - Multi-Byte String Extension
This section describes the mbstring (multi-byte string) extension library designed to help you manipulate non-ASCII character strings encoded in various encoding schemas like Unicode UTF-8.
PHP offers a nice extension called "mbstring (multi-byte string)" to help you manage non-ASCII strings. Here are the features
- Provides multibyte specific string functions that properly detect the beginning or ending
of a multibyte character. For example, mb_strlen() and mb_split().
- Handles character encoding conversion between the possible encoding pairs.
- Offers automatic encoding conversion for HTTP input and output.
- Supports 'function overloading' feature which enables you to add multibyte awareness
to regular string functions. For example, you can overload substr() with mb_substr(),
so that calling substr() is really calling mb_substr().
"mbstring" extension needs to installed and configured by updating the php.ini file.
To get started with "mbstring" features, I modified my php.ini as:
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = Off
mbstring.detect_order = auto
- "mbstring.language = Neutral" is really setting the language to UTF-8. I like to work with Unicode UTF-8 encoding.
- "mbstring.http_input = pass" means no decoding when receiving HTTP input. I like to manage the decoding myself inside my PHP script.
- "mbstring.http_output = pass" means no encoding when generating HTTP output. I like to manage the encoding myself inside my PHP script.
Last update: 2015.
Table of Contents
About This Book
Introduction and Installation of PHP 7.0
PHP Script File Syntax
PHP Data Types and Data Literals
Variables, References, and Constants
Expressions, Operations and Type Conversions
Conditional Statements - "if" and "switch"
Loop Statements - "while", "for", and "do ... while"
Function Declaration, Arguments, and Return Values
Arrays - Ordered Maps
Configuring and Sending out Emails
Retrieving Information from HTTP Requests
Creating and Managing Sessions in PHP Scripts
Sending and Receiving Cookies in PHP Scripts
Controlling HTTP Response Header Lines in PHP Scripts
MySQL Server Connection and Access Functions
Functions to Manage Directories, Files and Images
SOAP Extension Function and Calling Web Services
SOAP Server Functions and Examples
Localization Overview of Web Applications
Using Non-ASCII Characters in HTML Documents
Using Non-ASCII Characters as PHP Script String Literals
Receiving Non-ASCII Characters from Input Forms
►"mbstring" Extension and Non-ASCII Encoding Management
►"mbstring" - Multi-Byte String Extension
mb_convert_encoding() and Other mbstring Functions
Examples of Using "mbstring" Functions
Managing HTTP Input and Output Encoding
Managing Non-ASCII Character Strings with MySQL Servers
Introduction of Class and Object
Integrating PHP with Apache Web Server
PDF Printing Version