What is PHP Extension?
PHP is a server-side scripting language designed for web development. It uses modules/extensions to customize the needs and is not installed by default. PHP extensions are compiled libraries that enable specific functions for PHP code. It adds the missing features in the coding itself. In cPanel, PHP extensions can be installed directly with a graphic interface.
Steps to install PHP Extensions:
- Login to cPanel account
- Under Software and Service Section, select PHP version
- Enable the needed extensions and save it
What is mbstring extension?
Mbstring stands for multi-byte string functions to manage non-ASCII strings. It is used to convert strings to different encodings that deals with multiple encodings in PHP. It is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and also single-byte encodings.
Features of mbstring:
- Provides automatic encoding conversion between the possible encoding pairs.
- Supports function overloading for regular string functions.
- Handles character encoding conversion for possible encoding pairs.
- Provides multibyte specific string functions to detect the beginning and ending of multibyte characters. Example: mb_split() and mb_strlen().
- Handles Japanese characters and also can handle character encoding other than Japanese characters.
Steps to enable mbstring in cPanel:
- Login to cPanel
- Under Software, click Select PHP Version
- Select the PHP extension ‘mbstring’ and save.
What is iconv extension?
iconv is an extension that converts a string to the requested character encoding. It can convert a string represented by a local character set into one represented by another character set such as Unicode character set. This extension is enabled by default and it can be disabled by compiling with ‘–without-iconv’. The option ‘–with-iconv-dir‘ directive specifies the location of iconv on the system which is compiled by PHP or the default locations are scanned.
string iconv (String $in_charset, String $out_charset, String $str)
It converts a string str from in_charset to out_charset and returns the converted string or FALSE in the case of failure.
Functions of iconv:
iconv uses certain functions that are listed below
- iconv_get_encoding – Retrieves the internal configuration variables of iconv extension.
- iconv_mime_decode_headers – Decodes the multiple MIME header files once.
- iconv_mime_decode – Decodes a MIME header file.
- iconv_mime_encode – Composes a MIME header file.
- iconv_set_encoding – Set current setting for conversion of character encoding.
- iconv – Converts string to requested character encoding.
- iconv_strlen – Returns the character count of a string
- iconv_strpos – Finds the position of the first occurrence of a needle within a haystack.
- iconv_strrpos – Finds the last occurrence of a needle within a haystack.
- iconv_substr – Removes a part of the string.
- ob_iconv_handler – Converts the character encoding as output buffer handler.