my HTML header - any feedback?

Discussion in 'HTML' started by dittonamed, Jan 16, 2008.

  1. dittonamed

    dittonamed Guest

    I will be building a "template" from this to be included in each page
    of a PHP/JS/HTML project i'm starting soon, but I'm curious what other
    connoisseurs might think of my layout. Hmm like throwing the GET/POST
    processing between the <head> and <body> tags is a new idea, but it
    seems logical. Any caveats or anything watch out for?

    Any thoughts?

    Cheers!




    <?php
    # Header Output, cookies, session, auth, etc...
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <?php
    # includes for the head section
    ?>
    <!-- other head items, meta tags, javascript, css, title -->
    </head>

    <?php
    # processing php, ajax requests, POSTS, GETS, etc
    ?>

    <body>
    <?php
    # output php/html/etc
    ?>
    </body>
    </html>
     
    dittonamed, Jan 16, 2008
    #1
    1. Advertising

  2. dittonamed wrote:

    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


    (a) That triggers quirks mode rendering in some browsers
    (b) 4.0 was replaced by 4.01 fairly quickly
    (c) We're long past the transitional period, browsers have caught up now

    i.e. use HTML 4.01 Strict

    > <html>


    No lang attribute?

    > <?php
    > # processing php, ajax requests, POSTS, GETS, etc
    > ?>


    It seems odd to do this part way through the document. Especially so for
    responses to Ajax requests (which usually won't be HTML documents).

    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
     
    David Dorward, Jan 16, 2008
    #2
    1. Advertising

  3. ..oO(David Dorward)

    >dittonamed wrote:
    >
    >> <?php
    >> # processing php, ajax requests, POSTS, GETS, etc
    >> ?>

    >
    >It seems odd to do this part way through the document.


    ACK

    >Especially so for
    >responses to Ajax requests (which usually won't be HTML documents).


    It may also cause problems if the processing of form data should require
    a following redirect, which happens quite regularly in my own scripts to
    avoid a repost of the form data just by reloading the page in the
    browser. Every processing should be done before the first line of
    output, not somewhere in the middle of it.

    Micha
     
    Michael Fesser, Jan 16, 2008
    #3
  4. On Jan 16, 3:16 pm, dittonamed <> wrote:
    > I will be building a "template" from this to be included in each page
    > of a PHP/JS/HTML project i'm starting soon, but I'm curious what other
    > connoisseurs might think of my layout. Hmm like throwing the GET/POST
    > processing between the <head> and <body> tags is a new idea, but it
    > seems logical. Any caveats or anything watch out for?
    >
    > Any thoughts?
    >
    > Cheers!


    There's no advantage to processing in the middle of the output. It
    makes more sense not to separate your code into header and processing
    blocks. All processing should usually be done before any output so you
    don't end up with spaghetti code.

    You may want to look at the Model-View-Controller (Model2 for web)
    design pattern, and maybe check out some frameworks such as Code
    Igniter or Zend Framework. It should then be clear that processing is
    best done before any output.

    Good luck,
    -Michael Placentra II | PHP5 ZCE
     
    Mike Placentra II, Jan 17, 2008
    #4
  5. Mike Placentra II wrote:
    > On Jan 16, 3:16 pm, dittonamed <> wrote:
    >> I will be building a "template" from this to be included in each page
    >> of a PHP/JS/HTML project i'm starting soon, but I'm curious what other
    >> connoisseurs might think of my layout. Hmm like throwing the GET/POST
    >> processing between the <head> and <body> tags is a new idea, but it
    >> seems logical. Any caveats or anything watch out for?
    >>
    >> Any thoughts?
    >>
    >> Cheers!

    >
    > There's no advantage to processing in the middle of the output. It
    > makes more sense not to separate your code into header and processing
    > blocks. All processing should usually be done before any output so you
    > don't end up with spaghetti code.
    >


    Sure there is. It keeps the processing right where the results are
    being used. No more spaghetti code than doing everything up front.

    > You may want to look at the Model-View-Controller (Model2 for web)
    > design pattern, and maybe check out some frameworks such as Code
    > Igniter or Zend Framework. It should then be clear that processing is
    > best done before any output.
    >


    Not necessarily. And the MVC pattern doesn't necessarily require
    processing be done all at the beginning.

    > Good luck,
    > -Michael Placentra II | PHP5 ZCE
    >



    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
     
    Jerry Stuckle, Jan 17, 2008
    #5
  6. Mike Placentra II wrote:

    > There's no advantage to processing in the middle of the output. It makes
    > more sense not to separate your code into header and processing blocks.
    > All processing should usually be done before any output so you don't end
    > up with spaghetti code.


    My general technique nowadays is not to distinguish so much between
    processing and output. My PHP builds up a large object, representing the
    page, and at the end, I just run:

    print $page->toHTML;

    or somesuch. Only one print statement for the entire PHP script, and no
    HTML outside the <?php ... ?> block.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 23:00.]

    Gnocchi all'Amatriciana al Forno
    http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatriciana/
     
    Toby A Inkster, Jan 17, 2008
    #6
  7. On Jan 16, 8:16 pm, dittonamed <> wrote:

    > I will be building a "template" from this to be included in each page
    > of a PHP/JS/HTML project i'm starting soon, but I'm curious what other
    > connoisseurs might think of my layout. [...]
    >
    > <?php
    > # Header Output, cookies, session, auth, etc...
    > ?>
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


    As others have pointed out, this should be 4.01 Strict for new web
    pages; you're also missing the URL. Here's what you should have
    instead:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
    TR/html4/strict.dtd">
    (wrap as appropriate)


    --
    AGw.
     
    AGw. (Usenet), Jan 18, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newsgroup - Ann
    Replies:
    4
    Views:
    729
    lilburne
    Nov 2, 2003
  2. Karl
    Replies:
    1
    Views:
    360
    dorayme
    Dec 27, 2007
  3. mlt
    Replies:
    2
    Views:
    881
    Jean-Marc Bourguet
    Jan 31, 2009
  4. Henrik
    Replies:
    1
    Views:
    442
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
  5. Karl

    Creating a feedback form in html

    Karl, Dec 27, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    170
    Ted Zlatanov
    Dec 28, 2007
Loading...

Share This Page