Monday, December 22, 2025
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
32456 POSTS0 COMMENTS
Milvus
111 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11959 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12038 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6911 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS