I have a Document
class that is responsible for holding the document that will eventually be gzipped and then printed onto the page. In that Document holds the document's DocType. The Problem I am facing is how to correctly implement displaying the Doctype.
For example: I could create an array of popular Doctypes that are the most frequently used, and then if you enter 'strict', it would automatically pick HTML 4.01 Strict
. If there isn't a known DocType, it could assume you are entering in a custom DocType, and just display what you've entered. This seems a error prone and clumbsy.
$document->setDoctype("strict"); ..... in a class far, far, away........ function setDocType($type) { if(in_array($type, $this->doctypes)) { $this->doctype = $this->doctypes[$type]; } else { $this->doctype = $type; } }
Another way to do it would be to simply have to enter in the entire DocType every time.
$document->setDoctype('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
How would you deal with this problem?