my HTML header - any feedback?

my HTML header - any feedback?

am 16.01.2008 21:16:01 von dittonamed

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 and tags is a new idea, but it
seems logical. Any caveats or anything watch out for?

Any thoughts?

Cheers!




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




# includes for the head section
?>



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


# output php/html/etc
?>

Re: my HTML header - any feedback?

am 16.01.2008 21:51:05 von David Dorward

dittonamed wrote:

>

(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

>

No lang attribute?

> > # 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/

Re: my HTML header - any feedback?

am 16.01.2008 22:37:31 von Michael Fesser

..oO(David Dorward)

>dittonamed wrote:
>
>> >> # 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

Re: my HTML header - any feedback?

am 17.01.2008 04:32:45 von nothingsoriginalontheinternet

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 and 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

Re: my HTML header - any feedback?

am 17.01.2008 05:19:34 von Jerry Stuckle

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 and 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.
jstucklex@attglobal.net
==================

Re: my HTML header - any feedback?

am 17.01.2008 05:19:34 von Jerry Stuckle

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 and 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.
jstucklex@attglobal.net
==================

Re: my HTML header - any feedback?

am 17.01.2008 12:50:45 von Toby A Inkster

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 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-allamatrici ana/

Re: my HTML header - any feedback?

am 17.01.2008 12:50:45 von Toby A Inkster

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 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-allamatrici ana/

Re: my HTML header - any feedback?

am 18.01.2008 22:07:13 von Frederick

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. [...]
>
> > # Header Output, cookies, session, auth, etc...
> ?>
>
>

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:
TR/html4/strict.dtd">
(wrap as appropriate)


--
AGw.