HomeLanguagesPHP mb_http_input() Function

PHP mb_http_input() Function

The mb_http_input() is an inbuilt function in PHP that facilitates the HTTP input character encoding to be detected.

Syntax:

mb_http_input(?string $type = null): array|string|false

Parameter: 

  • type: This parameter takes values like “G” for GET, “P” for POST, “C” for COOKIE, “S” for string, “L” for the list, and “I” for the whole list which will return an array. If the type is missing then it returns the last input type processed.

Return Value: This function will return the character encoding name or an array of character encoding names, depending on the type. It returns “false” if the function does not process specified HTTP input.

Example 1: The following code demonstrates the mb_http_input() function.

PHP




<?php
// Get the character encoding of the HTTP input
$http_input_encoding = mb_http_input('I');
  
// Output the encoding
var_dump( $http_input_encoding);
?>


Output:

array(1) {
       [0]=> string(5) "UTF-8"
}    

Example 2: The following code demonstrates the mb_http_input() function.

PHP




<?php
$http_input_encoding = mb_http_input("G");
   
// Output the encoding
var_dump($http_input_encoding);
?>


Output:

bool(false) 

Reference: https://www.php.net/manual/en/function.mb-http-input.php

RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS