(PHP 4 >= 4.0.5, PHP 5, PHP 7)
iconv — ×Ö·û´®°´ÒªÇóµÄ×Ö·û±àÂëÀ´×ª»»
$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
¡£
//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 : ', $text, PHP_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