iconv

(PHP 4 >= 4.0.5, PHP 5, PHP 7)

iconv×Ö·û´®°´ÒªÇóµÄ×Ö·û±àÂëÀ´×ª»»

˵Ã÷

string iconv ( string $in_charset , string $out_charset , string $str )

½«×Ö·û´® str ´Ó in_charset ת»»±àÂëµ½ out_charset¡£

²ÎÊý

in_charset

ÊäÈëµÄ×Ö·û¼¯¡£

out_charset

Êä³öµÄ×Ö·û¼¯¡£

Èç¹ûÄãÔÚ out_charset ºóÌí¼ÓÁË×Ö·û´® //TRANSLIT£¬½«ÆôÓÃתд£¨transliteration£©¹¦ÄÜ¡£Õâ¸öÒâ˼ÊÇ£¬µ±Ò»¸ö×Ö·û²»Äܱ»Ä¿±ê×Ö·û¼¯Ëù±íʾʱ£¬Ëü¿ÉÒÔͨ¹ýÒ»¸ö»ò¶à¸öÐÎËƵÄ×Ö·ûÀ´½üËƱí´ï¡£ Èç¹ûÄãÌí¼ÓÁË×Ö·û´® //IGNORE£¬²»ÄÜÒÔÄ¿±ê×Ö·û¼¯±í´ïµÄ×Ö·û½«±»Ä¬Ä¬¶ªÆú¡£ ·ñÔò£¬str ´ÓµÚÒ»¸öÎÞЧ×Ö·û¿ªÊ¼½Ø¶Ï²¢µ¼ÖÂÒ»¸ö E_NOTICE¡£

str

Ҫת»»µÄ×Ö·û´®¡£

·µ»ØÖµ

·µ»Øת»»ºóµÄ×Ö·û´®£¬ »òÕßÔÚʧ°Üʱ·µ»Ø FALSE¡£

·¶Àý

Example #1 iconv() Àý×Ó

<?php
$text 
"This is the Euro symbol '€'.";

echo 
'Original : '$textPHP_EOL;
echo 
'TRANSLIT : 'iconv("UTF-8""ISO-8859-1//TRANSLIT"$text), PHP_EOL;
echo 
'IGNORE   : 'iconv("UTF-8""ISO-8859-1//IGNORE"$text), PHP_EOL;
echo 
'Plain    : 'iconv("UTF-8""ISO-8859-1"$text), PHP_EOL;

?>

ÒÔÉÏÀý³ÌµÄÊä³öÀàËÆÓÚ£º

Original : This is the Euro symbol '€'.
TRANSLIT : This is the Euro symbol 'EUR'.
IGNORE   : This is the Euro symbol ''.
Plain    :
Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
This is the Euro symbol '