Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: parse error

  1. #1
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking parse error

    I am very new to PHP. I am working on a tutorial and know I am typing the code exactly. Even so I get this parse error:
    Parse error: parse error, unexpected '!' in C:\FoxServ\www\internetexplorer.php on line 2
    Here is the code and any help is greatly appreciated
    <?php
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ! = = FALSE) {
    echo 'You are using Internet Explorer.<br />';
    }
    ?>

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    there should be no spaces in between the equal signs and the exclamation point.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much Ryan. You are absolutely correct. It's difficult to tell when spaces are used and when they are not. I really appreciate your help

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So, you detect the one browser still in common use that can't handle XHTML, then serve XHTML to it? Smart

    This is a terrible way to detect IE, since all sorts of browsers can have MSIE in the user agent string for various reasons (hey, to this day IE still tries to pass itself off as being Mozilla 4).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I think iv'e covered at least 99% of situations where a browser could be miscontrued as IE through the http user agent...
    http://boxxertrumps.bo.funpic.org/h.phps
    opera has "Opera" appended to the user agent string while saying its IE, and i remember twey telling me that some browsers have "like MSIE" in the http user agent string.
    but that statement should cover all of your bases.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Only as it currently stands that we know of, though: there's no guarantee that there isn't or won't be some browser out there that will fool your script. If you want to show something to IE only, use conditional comments.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I had forgotten about those.
    Would I be able to use that in my case? i would have to send a blank content type to override the default one, define the stuff in meta tags and im not sure what behavior would ensue...
    also, i didn't think conditional comments were useable in any other browser...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You can't define a blank content-type through any means. It's against the standard. No, it can't be used to change the content type, since that's outside the HTML. There is currently no effective way to send the text/html content type to IE only. You can do the <meta> tags, but remember that they shouldn't be vital to your page's working: <meta> elements are by nature optional, and should be able to be ignored at the browser's discretion.
    also, i didn't think conditional comments were useable in any other browser...
    Depends what you mean by "useable." Other browsers don't recognise them as anything special, no, but the point of them is that there's no need to.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boxxertrumps View Post
    I think iv'e covered at least 99&#37; of situations where a browser could be miscontrued as IE through the http user agent...
    http://boxxertrumps.bo.funpic.org/h.phps
    It's certainly impossible to always distinguish a spoofed browser from the real thing, but that's why browser detection is a bad idea and should be avoided. Especially server-side.

    Regardless, serving XHTML to everything other than IE is ridiculous. Who said that IE is the only user agent that doesn't support XHTML? If you must serve XHTML, use content type-oriented content negotiation. That is the only sensible way to do it. However, why not opt for the far more reasonable choice: forgo XHTML completely - unless a task is impossible without it.

    Mike
    Last edited by mwinter; 05-06-2007 at 08:18 AM.

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you must serve XHTML, use content negotiation.
    Except that IE sends Accept: */*, so by the laws of content negotiation one should send it XHTML.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •