
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP – Set the current setting for character encoding conversion using iconv_set_encoding() function
In PHP, the iconv_set_encoding() function is used to set the current character encoding conversion. It is an inbuilt function in PHP that changes the value of the internal configuration variable specified by type to encoding.
Syntax
string iconv_set_encoding(string $type, string $encoding)
Parameters
iconv_set_encoding() takes two parameters − $type and $encoding.
$type − The $type parameter can be input_encoding, output_encoding or internal_encoding.
$encoding − The $encoding parameter is used for the character set.
Return Values
iconv_set_encoding() returns True on success and False on failure.
Example
<pre> <?php // internal_encoding is string $type //UTF-8 is string $charset $bool = iconv_set_encoding ("internal_encoding","UTF-8"); // it will shows the new encoding $mixed = iconv_get_encoding(); var_dump($mixed); ?> </pre>
Output
array(3) { ["input_encoding"]=> string(5) "UTF-8" ["output_encoding"]=> string(5) "UTF-8" ["internal_encoding"]=> string(5) "UTF-8" }
- Related Articles
- PHP – Convert a string to a requested character encoding using iconv()
- PHP – How to set the character encoding detection order using mb_detect_order()?
- PHP – Get or set the HTTP output character encoding with mb_http_output()
- How to set encoding in PHP FPDI library?
- PHP – How to detect character encoding using mb_detect_encoding()
- PHP – Detect HTTP input character encoding with mb_http_input()
- Node.js – Retrieving file character encoding
- PHP – Check if strings are valid for the specified encoding using mb_check_encoding()
- Detect base64 encoding in PHP?
- How to include the character encoding in HTML?
- SHA encoding using Python?
- PHP – Get aliases of a known encoding type using mb_encoding_aliases()
- Encoding string based on character frequency in JavaScript
- MD5 hash encoding using Python?
- Convert ASCII TO UTF-8 Encoding in PHP?

Advertisements