Форум: Форум PHPФорум ApacheФорум Регулярные ВыраженияФорум MySQLHTML+CSS+JavaScriptФорум FlashРазное
Новые темы: 0000000
PHP. Практика создания Web-сайтов (второе издание). Авторы: Кузнецов М.В., Симдянов И.В. Самоучитель PHP 5 / 6 (3 издание). Авторы: Кузнецов М.В., Симдянов И.В. MySQL на примерах. Авторы: Кузнецов М.В., Симдянов И.В. PHP 5/6. В подлиннике. Авторы: Кузнецов М.В., Симдянов И.В. PHP на примерах (2 издание). Авторы: Кузнецов М.В., Симдянов И.В.
ВСЕ НАШИ КНИГИ
Консультационный центр SoftTime

Форум PHP

Выбрать другой форум

 

Здравствуйте, Посетитель!

вид форума:
Линейный форум Структурный форум

тема: Принял клиент HTTP-заголовок или нет
 
 автор: xenux   (09.12.2006 в 00:54)   письмо автору
 
 

Как узнать в пхп принел ли браузер header?

хороше бы чтоб ктонибудь написал статью про заголовки.

Помогите разобраться.


Вот такая задача .
Choosing MIME Types Dynamically

Another option is to detect the MIME types that can be handled by a user agent and choose the MIME type dynamically. For example, if your server finds out that a certain user agent can handle the "application/vnd.wap.xhtml+xml" MIME type, then all your XHTML MP documents will be delivered as "application/vnd.wap.xhtml+xml" to this user agent.

To choose the MIME type dynamically, you need to write a few lines of code using a server-side scripting language (e.g. ASP, JSP, Perl, PHP). The pseudo-code is shown below:

1.

Obtain the accept header value of the HTTP request received. The accept header contains all MIME types that can be handled by the client user agent that sends the request.
2.

If the accept header value contains "application/vnd.wap.xhtml+xml", set the MIME type of the XHTML MP document to "application/vnd.wap.xhtml+xml".
Else if the accept header value contains "application/xhtml+xml", set the MIME type of the XHTML MP document to "application/xhtml+xml".
Else set the MIME type of the XHTML MP document to "text/html".

The following example demonstrates how to use JSP to write the code. If you use a server-side technology other than JSP, the code will be slightly different but the idea is the same.


<%
String acceptHeader = request.getHeader("accept");

if (acceptHeader.indexOf("application/vnd.wap.xhtml+xml") != -1)
response.setContentType("application/vnd.wap.xhtml+xml");
else if (acceptHeader.indexOf("application/xhtml+xml") != -1)
response.setContentType("application/xhtml+xml");
else
response.setContentType("text/html");
%>

   
 
 автор: xenux   (10.12.2006 в 14:54)   письмо автору
 
   для: xenux   (09.12.2006 в 00:54)
 

Вот вроде правильно !!!


<?php $accept $_SERVER["HTTP_ACCEPT"];
$findme="application/vnd.wap.xhtml+xml";
$pos strpos($accept$findme);
if (
$posheader('Content-type: application/vnd.wap.xhtml+xml');
else
$findme="application/xhtml+xml";
$pos strpos($accept$findme);
if (
$pos)  header('Content-type: application/xhtml+xml');
else  
header('Content-type: application/xhtml+xml');
?>

   
Rambler's Top100
вверх

Rambler's Top100 Яндекс.Метрика Яндекс цитирования