web\Request parseAcceptHeader()

parseAcceptHeader() public method

Parses the given Accept (or Accept-Language) header.

This method will return the acceptable values with their quality scores and the corresponding parameters as specified in the given Accept header. The array keys of the return value are the acceptable values, while the array values consisting of the corresponding quality scores and parameters. The acceptable values with the highest quality scores will be returned first. For example,

$header = 'text/plain; q=0.5, application/json; version=1.0, application/xml; version=2.0;';
$accepts = $request->parseAcceptHeader($header);
print_r($accepts);
// displays:
// [
//     'application/json' => ['q' => 1, 'version' => '1.0'],
//      'application/xml' => ['q' => 1, 'version' => '2.0'],
//           'text/plain' => ['q' => 0.5],
// ]
public array parseAcceptHeader ( $header )
$header string

The header to be parsed

return array

The acceptable values ordered by their quality score. The values with the highest scores will be returned first.

doc_Yii
2016-10-30 17:15:59
Comments
Leave a Comment

Please login to continue.