Monday, September 23, 2024
Google search engine
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

Recent Comments