Open In App

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: 

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
// 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
$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

Article Tags :