
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set Character Encoding Conversion Using iconv_set_encoding Function in PHP
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" }
Advertisements