HTTP 函数
PHP Manual

http_negotiate_content_type

(PECL pecl_http >= 0.19.0)

http_negotiate_content_typeNegotiate clients preferred content type

说明

string http_negotiate_content_type ( array $supported [, array &$result ] )

This function negotiates the clients preferred content type based on its Accept HTTP header. The qualifier is recognized and content types without qualifier are rated highest.

参数

supported

array containing the supported content types as values

result

will be filled with an array containing the negotiation results

返回值

Returns the negotiated content type or the default content type (i.e. first array entry) if none match.

范例

Example #1 Using http_negotiate_content_type()

<?php
$content_types 
= array('application/xhtml+xml''text/html');
http_send_content_type(http_negotiate_content_type($content_types));
?>


HTTP 函数
PHP Manual