Dreamweaver, PHP and XHTML compliance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Captain Nemo

    Dreamweaver, PHP and XHTML compliance

    Hi

    I'm essentially a back-end programmer so I don't know very much about
    Dreamweaver. However, I work with web-designers who are keen for me to
    write my pages using Dreamweaver templates.

    One problem that has emerged straight away is that of XHTML compliance. I
    understand (and please correct me if I'm wrong) that in order to achieve
    this, every document must start with a line like:

    <?xml version="1.0" encoding="iso-8859-1"?>

    However, this won't work in PHP, because as soon as it sees the '<?' it
    assumes that what follows is php code (and crashes).

    It's simple enough to add the line:

    <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>

    at the top of your PHP pages, but then it won't work in plain HTML, so it
    can't go in the template. What we need is version 1 of the line in HTML
    docs and version 2 in PHP docs.

    Does anyone know the answer to this problem?



  • Ian Rastall

    #2
    Re: Dreamweaver, PHP and XHTML compliance

    On Mon, 13 Dec 2004 13:33:47 GMT, "Captain Nemo"
    <Captain@NoSpam .com> wrote:
    [color=blue]
    >One problem that has emerged straight away is that of XHTML compliance. I
    >understand (and please correct me if I'm wrong) that in order to achieve
    >this, every document must start with a line like:
    >
    ><?xml version="1.0" encoding="iso-8859-1"?>
    >
    >However, this won't work in PHP, because as soon as it sees the '<?' it
    >assumes that what follows is php code (and crashes).
    >[...]
    >Does anyone know the answer to this problem?[/color]

    From what I understand, you only need to use an XML declaration if
    you're serving your XHTML page as XML. Since browsers still have a
    problem with that, most people serve it as text/html. So you don't
    need that opening bit, and will still be standards compliant.
    Here's further reading from the W3C:

    W3C i18n tutorial: What you need to know about character encodings and characters in HTML and CSS.


    Ian
    --


    Comment

    • Michael Fesser

      #3
      Re: Dreamweaver, PHP and XHTML compliance

      .oO(Captain Nemo)
      [color=blue]
      >I'm essentially a back-end programmer so I don't know very much about
      >Dreamweaver. However, I work with web-designers who are keen for me to
      >write my pages using Dreamweaver templates.
      >
      >One problem that has emerged straight away is that of XHTML compliance. I
      >understand (and please correct me if I'm wrong) that in order to achieve
      >this, every document must start with a line like:
      >
      ><?xml version="1.0" encoding="iso-8859-1"?>[/color]

      Nope. While the XML prolog is recommended, it's not always necessary.
      It's used to specify the used encoding, but this can/should also be done
      in the response header sent by the server (with a charset parameter in
      the content-type header). Additionally using such a prolog will kick
      Internet Explorer into quirks mode.
      [color=blue]
      >However, this won't work in PHP, because as soon as it sees the '<?' it
      >assumes that what follows is php code (and crashes).[/color]

      That's because short_open_tags are enabled on the server.
      [color=blue]
      >It's simple enough to add the line:
      >
      ><?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>[/color]

      Ugly.

      I would rather turn short_open_tags off (along with register_global s and
      magic_quotes_gp c).
      [color=blue]
      >at the top of your PHP pages, but then it won't work in plain HTML, so it
      >can't go in the template. What we need is version 1 of the line in HTML
      >docs and version 2 in PHP docs.
      >
      >Does anyone know the answer to this problem?[/color]

      First you should ask the designers why they insist on using XHTML.
      HTML 4.01 Strict is more than enough in most cases unless you know
      exactly what you're doing. Currently there's little to no reason to use
      XHTML. Only the most recent browsers like Opera and Mozilla really
      support it, for others like IE you have to deliver it as text/html,
      which makes no sense at all and may cause new problems.

      Sending XHTML as text/html Considered Harmful


      Micha

      Comment

      • Pedro Graca

        #4
        Re: Dreamweaver, PHP and XHTML compliance

        Captain Nemo wrote:[color=blue]
        > However, this won't work in PHP, because as soon as it sees the '<?' it
        > assumes that what follows is php code (and crashes).
        >
        > It's simple enough to add the line:
        >
        > <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>
        >
        > at the top of your PHP pages, but then it won't work in plain HTML, so it
        > can't go in the template. What we need is version 1 of the line in HTML
        > docs and version 2 in PHP docs.
        >
        > Does anyone know the answer to this problem?[/color]

        You could try "short_open _tag = off"
        PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


        --
        Mail to my "From:" address is readable by all at http://www.dodgeit.com/
        == ** ## !! ------------------------------------------------ !! ## ** ==
        TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
        may bypass my spam filter. If it does, I may reply from another address!

        Comment

        Working...