htmlHelper::setDocType PHP Method

setDocType() public method

Can either set to an actual doctype definition or to one of the presets (case-insensitive): XHTML Mobile 1.2 XHTML Mobile 1.1 XHTML Mobile 1.0 Mobile 1.2 (alias for XHTML Mobile 1.2) Mobile 1.1 (alias for XHTML Mobile 1.1) Mobile 1.0 (alias for XHTML Mobile 1.0) Mobile (alias for the most-strict Mobile DTD, currently 1.2) XHTML 1.1 (this is the default DTD, there is no need to apply this method for an XHTML 1.1 doctype) XHTML (Alias for XHTML 1.1) XHTML 1.0 Strict XHTML 1.0 Transitional XHTML 1.0 Frameset XHTML 1.0 (Alias for XHTML 1.0 Strict) HTML 5 HTML 4.01 HTML (Alias for HTML 4.01)
public setDocType ( string $docType )
$docType string
    public function setDocType($docType)
    {
        $docType = str_replace(' ', '', strtolower($docType));
        if ($docType == 'xhtml1.1' || $docType == 'xhtml') {
            return;
            //XHTML 1.1 is the default
        } else {
            if ($docType == 'xhtml1.0') {
                $docType = 'strict';
            }
        }
        $docType = str_replace(array('xhtml mobile', 'xhtml1.0'), array('mobile', ''), $docType);
        $docTypes = array('mobile1.2' => '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" ' . '"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">', 'mobile1.1' => '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN ' . '"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">', 'mobile1.0' => '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" ' . '"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">', 'strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', 'transitional' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', 'frameset' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', 'html4.01' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" ' . '"http://www.w3.org/TR/html4/strict.dtd">', 'html5' => '<!DOCTYPE html>');
        $docTypes['mobile'] = $docTypes['mobile1.2'];
        $docTypes['html'] = $docTypes['html4.01'];
        $this->_docType = isset($docTypes[$docType]) ? $docTypes[$docType] : $docType;
    }