PHP
 Computer >> コンピューター >  >> プログラミング >> PHP

PHP – mb_http_output()を使用してHTTP出力文字エンコードを取得または設定します


mb_http_output() PHPの関数は、HTTP出力文字エンコードを取得または設定するために使用されます。この関数が呼び出された後の出力は、設定された内部エンコーディングから指定されたエンコーディングに変換されます。

構文

string|bool mb_http_output(str $encoding = null)

パラメータ

mb_http_output() 単一のパラメータのみを受け入れる-

  • $ encoding −HTTP出力文字エンコーディングをエンコーディングに設定するために使用されます。エンコーディングを省略した場合は、 mb_http_output() 現在のHTTP出力文字エンコードを返します。

戻り値

エンコーディングを省略した場合、 mb_http_output() 関数は、現在のHTTP出力文字エンコードを返します。それ以外の場合は、成功するとTrueを返し、失敗するとFalseを返します。

<?php
   // It will return the output character encoding
   $string = mb_http_output();
   var_dump($string);
?>

出力

次の出力が生成されます-

string(5) "UTF-8"

  1. PHPで変数名を文字列として取得するにはどうすればよいですか?

    PHPで変数名を文字列として取得するには、コードは次のとおりです- 例 <?php    $a = "This is it!";    $$a = "Demo string!";    print($a); ?> 出力 これにより、次の出力が生成されます- This is it! 例 別の例を見てみましょう- <?php    $val = "This is it!";    function display($v

  2. C#のStringDictionaryで指定されたキーに関連付けられた値を取得または設定します

    StringDictionaryで指定されたキーに関連付けられた値を取得または設定するには、コードは次のとおりです- 例 using System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict = new StringDictionary ();       strDict.Add("A", "