Forgive me if this thread is too broad....
As I am about to embark on the construction of some new websites built on PHP, I would like to make them as modern as possible. It's been awhile since I built any from scratch so I thought I'd ask the community about a few things so as to keep current with what the kids are doing these days.
1 - XHTML or HTML?
says that this example document conforms to the XML syntax of HTML5:
<?xml version="1.0" encoding="UTF-8"?>
That page also says this document conforms to the HTML syntax:
Note in particular the simplicity of the doctype declaration.
Does anyone have any anecodotes about why they chose XHTML vs. HTML or vice versa?
2 - HTML4 or HTML5?
It seems pretty clear to me that we should try to use the latest, but I worry about old browsers and wonder how they might respond to the extremely simple doctype declaration (what with no DTD and all).
3 - What media type?
The character encoding
advice from w3.org says that HTML documents need either text/html
media type or text/html-sandboxed
media type. I find myself wondering under what conditions one would use the sandbox type and what protections this might bring me.
XHTML documents need either application/xhtml+xml
And how do we deliver these media types? Can we rely on Apache or should we always take care to use the [man]header[/man function?
4- What character encoding?
I've noticed that everyone seems to be using UTF-8 these days because it supports a wide range of languages and is compatible with most ASCII text you see (with some problems when extended ASCII is used -- wired
I'm looking at you). Does anyone have trouble specifying the encoding with their text editors these days? When serving these documents, how do we specify the charset?
* using [man]header[/man] and declaring content-type?
* Use a Byte-Order-Mark (BOM) in the file itself?
* Using a meta element with a charset attribute that specifies the encoding within the first 1024 bytes of the document?
5 - Template Engines: How do we separate PHP logic from HTML and styling?
Obviously it's good to separate your application and business logic from its presentation -- this makes it easy to output your content to different delivery platforms such as desktop/mobile phone/tablet. It also makes it easy to re-style your entire site without having to edit your primary logic files.
On the other hand, template engines often require extra steps to package up your data in an array or other merge format so that it can be handed to a template engine and one often has to learn some bizarre new looping syntax when dealing with data collections (or nested data collections -- *shudder*). There are also performance considerations -- merging data with some kind of parsed template can affect server peformance.