iconv

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

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

˵Ã÷

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

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

²ÎÊý

in_charset

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

out_charset

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

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

Caution

//TRANSLIT ÔËÐÐϸ½Ú¸ß¶ÈÒÀÀµÓÚϵͳµÄ iconv() ʵÏÖ£¨²Î¼û ICONV_IMPL£©¡£ ¾ÝϤ£¬Ä³Ð©ÏµÍ³ÉϵÄʵÏÖ»áÖ±½ÓºöÂÔ //TRANSLIT£¬ËùÒÔת»»Ò²ÓпÉÄÜʧ°Ü£¬out_charset »áÊDz»ºÏ¸ñµÄ¡£

str

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

·µ»ØÖµ

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

¸üÐÂÈÕÖ¾

°æ±¾ ˵Ã÷
5.4.0 Õâ¸ö°æ±¾Æð£¬×Ö·û·Ç·¨Ê±ºò»á·µ»Ø FALSE£¬³ý·ÇÔÚÊä³ö×Ö·ûÀïÖ¸¶¨ÁË //IGNORE ¡£ ÔÚ֮ǰ°æ±¾£¬Ëü»á·µ»ØÒ»²¿·Ö×Ö·û´®¡£

·¶Àý

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