WRInaute occasionnel
Salut à tous chers WRInautes
Je partage avec vous un petit morceau de code source PHP.
Il permet de déterminer quel est le doctype d'une page web (de manière non-formelle), si vous en avez besoin, copiez le !
Normalement vous n'aurez rien à redire... mais on ne sais jamais... Vous avez un avis ?
Peace
Je partage avec vous un petit morceau de code source PHP.
Il permet de déterminer quel est le doctype d'une page web (de manière non-formelle), si vous en avez besoin, copiez le !
PHP:
<span class="syntaxdefault"><? $a</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">strtolower</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'La première ligne non-vide d'</span><span class="syntaxdefault">une page web</span><span class="syntaxkeyword">.</span><span class="syntaxstring">');<br />if (strpos($a,'</span><span class="syntaxdefault">html 4.01 transitional</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">HTML 4.01 Transitional</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">html 4.01 frameset</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">HTML 4.01 Frameset</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">html 4.01</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">HTML 4.01 Strict</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml 1.0 strict</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML 1.0 Strict</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml 1.0 transitional</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML 1.0 Transitional</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml 1.0 frameset</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML 1.0 Frameset</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml 1.1</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML 1.1 </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> DTD</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml basic 1.1</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML Basic 1.1</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">doctype html</span><span class="syntaxkeyword">></span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">HTML 5</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">math system</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">MathML 1.01</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">math public</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">MathML 2.0</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">mathml 2.0</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> MathML </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> SVG</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">svg 1.1 tiny</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">SVG 1.1 Tiny</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">svg 1.1 basic</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">SVG 1.1 Basic</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">svg 1.1</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">SVG 1.1 Full</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">svg 1.0</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">SVG 1.0</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">html 2.0</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault"> HTML 2.0</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">html 3.2</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">HTML 3.2</span><span class="syntaxstring">';<br />elseif (strpos($a,'</span><span class="syntaxdefault">xhtml basic 1.0</span><span class="syntaxstring">')) $b='</span><span class="syntaxdefault">XHTML Basic 1.0</span><span class="syntaxstring">';<br />else $b='</span><span class="syntaxdefault">Doctype inconnu selon W3C </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">juillet 2012</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">echo </span><span class="syntaxstring">"Résultat : $b"</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> ?></span>
Normalement vous n'aurez rien à redire... mais on ne sais jamais... Vous avez un avis ?
Peace