PHP - convert_cyr_string() 函式



PHP 的 convert_cyr_string() 函式用於將字串從一種西裡爾字母字元集轉換為另一種。

此函式允許您將字串的編碼從一種西裡爾字母指令碼更改為另一種,例如從 KOI8-R 更改為 Windows-1251,或從 UTF-8 更改為 ISO-8859-5。

從 PHP 7.4.0 版本開始,此函式已被棄用,從 PHP 8.0.0 版本開始,此函式已被移除

語法

以下是 PHP convert_cyr_string() 函式的語法:

convert_cyr_string ( string $str , string $from , string $to ): string 

引數

此函式接受三個引數,如下所示:

  • str - 需要轉換的字串。
  • from - 它表示源西裡爾字母字元集,為單個字元。
  • to - 它表示目標西裡爾字母字元集,為單個字元。

返回值

此函式返回轉換後的字串。

示例

以下程式演示了 PHP convert_cyr_string() 函式的使用:

<?php
   $str = "tutorials Point ";
   echo convert_cyr_string($str,'w','a'); 
?>

輸出

執行上述程式後,將出現以下錯誤,因為此函式已“棄用”:

PHP Fatal error:  Uncaught Error: Call to undefined function convert_cyr_string() in C:\Apache24\htdocs\index.php:3
Stack trace:
#0 {main}
  thrown in C:\Apache24\htdocs\index.php on line 3
php_function_reference.htm
廣告