SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check for wap support

    Hello!

    I would like to know how can I check if the browser has wap support? I would like the following scenario: if someone hits my page from a mobile phone or pda, he must see the wap version. If he hits the page from a pc, show the xhtml version.

    Thanks.

  2. #2
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I cheat on this one - I tell my mobile users to go to wap.domain.com or mobile.domain.com. It's possible that you can sniff the Accept request header (should be in $_SERVER['HTTP_ACCEPT']), serve up the WAP version if it's preferred over XHTML, and serve up XHTML otherwise. No idea how reliable this is, though, as I've no idea how many browsers send a reliable Accept header.

    From the HTTP/1.1 spec:
    Quote Originally Posted by RFC2616
    If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.
    So to conform to spec you can serve up XHTML any time the Accept header is not present; when it is, you should look for WAP or XHTML and server the preferred one. And to strictly conform to spec, respond with a 406 header (header("HTTP/1.1 406 Not Acceptable") if neither WAP nor XHTML (nor any other method you support) is specified in the Accept header.
    PHP questions? RTFM
    MySQL questions? RTFM


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •