PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > DOCTYPE
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
DOCTYPE

Réponse
 
LinkBack Outils de la discussion
Vieux 27/02/2008, 22h27   #1
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut DOCTYPE

here's what I'm using for my PHP files:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


1) Is that standard, and the only way it should be?

2) with that meta tag declaring utf-8, is it imperative that my
MySQL tables also use utf-8? (I have them at latin 1 now.)
  Réponse avec citation
Vieux 27/02/2008, 23h09   #2
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

..oO(Jerry)

>here's what I'm using for my PHP files:
>
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
><html xmlns="http://www.w3.org/1999/xhtml">
><head>
><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


Transitional doesn't really make sense for new sites, since you're not
transitioning from anything. And neither does XHTML, unless you have an
explicit need for it and know exactly what you're doing.

Remember: The most used browser on earth still doesn't understand real
XHTML and XHTML 2.0 - if it will ever reach a usable state - will _not_
be backwards-compatible to the current XHTML versions 1.0 and 1.1.

HTML 4.01 Strict(!) is still the document type of choice in most cases.

>2) with that meta tag declaring utf-8, is it imperative that my
>MySQL tables also use utf-8? (I have them at latin 1 now.)


You can drop it. Its only use is if documents are served without a web
server, for example a copy stored on the user's local disk. But in Web
context these meta thingies are useless. What matters is the HTTP header
sent by the server.

The answer to the question is "depends". Usually if you want your output
to be UTF-8, then it's a very good idea to use UTF-8 everywhere, from
the DB through the scripts to the final HTML. Of course you can keep
your data in Latin-1 and let the DB convert it automatically when it's
transfered to your script, but why would you want that? Such character
conversions are always prone to problems and should be avoided if
possible.

In short: If you want to use UTF-8, you should do it consistently.

Micha
  Réponse avec citation
Vieux 28/02/2008, 02h19   #3
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Michael Fesser wrote:
> .oO(Jerry)
>
>> here's what I'm using for my PHP files:
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

>
> Transitional doesn't really make sense for new sites, since you're not
> transitioning from anything. And neither does XHTML, unless you have an
> explicit need for it and know exactly what you're doing.


thanks. That's curious, because everything that I quoted above is
what is inserted by Dream Weaver for new PHP files.

> HTML 4.01 Strict(!) is still the document type of choice in most cases.


....

> In short: If you want to use UTF-8, you should do it consistently.


My conclusion after just now reading up is that I shouldn't want
to. My visitors will all be US or Western Europe. Latin 1 (aka
8859-1) is what is served by the webserver (although it also
accepts UTF-8). Latin-1 is also the default for PHP.

I also just noticed that Dream Weaver doesn't even offer Latin 1
as an option for the default encoding - so maybe it is DW that is
wacky.


  Réponse avec citation
Vieux 28/02/2008, 03h41   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jerry wrote:
> Michael Fesser wrote:
>> .oO(Jerry)
>>
>>> here's what I'm using for my PHP files:
>>>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

>>
>> Transitional doesn't really make sense for new sites, since you're not
>> transitioning from anything. And neither does XHTML, unless you have an
>> explicit need for it and know exactly what you're doing.

>
> thanks. That's curious, because everything that I quoted above is what
> is inserted by Dream Weaver for new PHP files.
>


That's your first mistake. Don't let ANY product do ANYTHING for you
unless you understand what it's doing. Learn HTML and you'll be much
better off.

The best HTML editor in the world is notepad on windows or vi on
Linux/unix. They force you to learn how to do it right.

>> HTML 4.01 Strict(!) is still the document type of choice in most cases.

>
> ...
>
>> In short: If you want to use UTF-8, you should do it consistently.

>
> My conclusion after just now reading up is that I shouldn't want to. My
> visitors will all be US or Western Europe. Latin 1 (aka 8859-1) is what
> is served by the webserver (although it also accepts UTF-8). Latin-1 is
> also the default for PHP.
>
> I also just noticed that Dream Weaver doesn't even offer Latin 1 as an
> option for the default encoding - so maybe it is DW that is wacky.
>
>
>


See above.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 28/02/2008, 12h03   #5
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> HTML 4.01 Strict(!) is still the document type of choice in most cases.

NACK. Since HTML incontrast to XHTML allows some very strange things,
XHTML is much easier to debug using a validator. Indeed, most of the
stuff (except some specialties like checked="checked", <br /> ...) sane
people are using in HTML is already XHTML.
Defining it als XHTML has the advantage, that constructions that are
commonly mistakes but are valid will be found by the validator.
  Réponse avec citation
Vieux 28/02/2008, 12h13   #6
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

On Thu, 28 Feb 2008 13:03:45 +0100, Jonas Werres <jonas@example.org> wrote:

>> HTML 4.01 Strict(!) is still the document type of choice in most cases.

>
> NACK. Since HTML incontrast to XHTML allows some very strange things,
> XHTML is much easier to debug using a validator. Indeed, most of the
> stuff (except some specialties like checked="checked", <br /> ...) sane
> people are using in HTML is already XHTML.
> Defining it als XHTML has the advantage, that constructions that are
> commonly mistakes but are valid will be found by the validator.


Writing HTML strict is at least as easy as XHTML, and easily validated.
Some major browser whose name shall not be mentioned still doesn't support
real XHTML, untill then there's no good reason to use XHTML. The XHTML
hype is past us, most serious HTML developers/designers are back to HTML
strict as using XHTML little to no advantages due to browser's
implementation. It's been shelved as 'could be usefull in the future,
certainly not now'. Even the w3c have kind of given up on it, and focus
more on HTML5 then XHTML2.

I'd be curious as to what 'constructions that are commonly mistakes but
are valid' are more easily found in XHTML then HTML, care to give an
example?

Offcourse, I'd love to use SVG or MathML in pages. Support is sadly
lacking.
--
Rik Wasmus
  Réponse avec citation
Vieux 28/02/2008, 14h46   #7
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jerry Stuckle wrote:
>>
>> I also just noticed that Dream Weaver doesn't even offer Latin 1 as an
>> option for the default encoding - so maybe it is DW that is wacky.


On further checking, DW offers "Western European" as an option,
and if I choose that then ISO-8859-1 is what actually gets
inserted into the (mostly useless) meta-tag. So that makes 3
synonyms for the same charset.

Also, after thinking a bit, the fact that the output originates
dynamically as php shouldn't matter, right? If I were to download
my php page, save the source as *.html, and then publish that
file as *.html, then the end result is the same - as far as
DOCTYPE goes.

So this was really an HTML question, independent of whether that
the output originated as php.
  Réponse avec citation
Vieux 28/02/2008, 15h18   #8
Dikkie Dik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> ..., DW offers "Western European" as an option, and if I
> choose that then ISO-8859-1 is what actually gets inserted into the
> (mostly useless) meta-tag. So that makes 3 synonyms for the same charset.
>
> Also, after thinking a bit, the fact that the output originates
> dynamically as php shouldn't matter, right? If I were to download my php
> page, save the source as *.html, and then publish that file as *.html,
> then the end result is the same - as far as DOCTYPE goes.


Not entirely. The best way to send the character set is _outside_ the
document itself. It is a strange that you should parse the character set
used out of the encoded document. What about utf-16? or utf-32? Could
you parse those character sets as easily out of a documented that is
written in it? Off course not. And if you can, there is no reason to do
so anymore.

So character sets are sent in a header. PHP supports this in two ways:
- set the default document type and character set in your PHP.ini,
- send a header your self with the header() function;

Especially the first way can be tricky is you do not realize it. Your
server may be sending "Content-type: text/html; charset=utf-8" in a
header, while your code may contain "Content-type: text/html;
charset=iso-8859-1" in a meta tag. Which of them is true?

> So this was really an HTML question, independent of whether that the
> output originated as php.


As you saw above, not entirely. Plain static HTML files have no control
over their headers.

Best regards.
  Réponse avec citation
Vieux 28/02/2008, 16h30   #9
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> I'd be curious as to what 'constructions that are commonly mistakes but
> are valid' are more easily found in XHTML then HTML, care to give an
> example?


Sure. This is valid HTML 4.01 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>Title</title>
<h1>Text</h1>
<p>
<select name="Choice" size="1">
<option>1. Entry
<option>2. Entry
<option>3. Entry
</select>
</p>
Notice missing <head>, <body>, </option>.

Try to check this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>Title</title>
<h1>Text</h1>
<p>
a< b
</p>
It is valid. But don't try to remove the space:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>Title</title>
<h1>Text</h1>
<p>
a<b
</p>
Ha. Broken.

Want it really bad? Try
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<>
<title//
<p ltr<span></span</p>
</>
is valid. At least there are warnings now at validator.w3.org. Long time
there weren't.

Having to close <br /> and stuff are peanut compared to all the SGML
stuff XHTML left behind. That's what I meant when I wrote, that the HTML
a sane person writes IS mostly XHTML.
  Réponse avec citation
Vieux 28/02/2008, 16h30   #10
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

..oO(Jonas Werres)

>> HTML 4.01 Strict(!) is still the document type of choice in most cases.

>
>NACK. Since HTML incontrast to XHTML allows some very strange things,
>XHTML is much easier to debug using a validator.


Only if you use a schema validator. The W3 validator is SGML-based,
which is not appropriate for validating X(HT)ML.

Micha
  Réponse avec citation
Vieux 28/02/2008, 16h46   #11
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jonas Werres wrote:
>> I'd be curious as to what 'constructions that are commonly mistakes
>> but are valid' are more easily found in XHTML then HTML, care to give
>> an example?

>
> Sure. This is valid HTML 4.01 Strict:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <title>Title</title>
> <h1>Text</h1>
> <p>
> <select name="Choice" size="1">
> <option>1. Entry
> <option>2. Entry
> <option>3. Entry
> </select>
> </p>
> Notice missing <head>, <body>, </option>.
>
> Try to check this:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <title>Title</title>
> <h1>Text</h1>
> <p>
> a< b
> </p>
> It is valid. But don't try to remove the space:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <title>Title</title>
> <h1>Text</h1>
> <p>
> a<b
> </p>
> Ha. Broken.
>
> Want it really bad? Try
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <>
> <title//
> <p ltr<span></span</p>
> </>
> is valid. At least there are warnings now at validator.w3.org. Long time
> there weren't.
>
> Having to close <br /> and stuff are peanut compared to all the SGML
> stuff XHTML left behind. That's what I meant when I wrote, that the HTML
> a sane person writes IS mostly XHTML.
>


Just because the validator doesn't catch all errors doesn't mean you
shouldn't use HTML 4.01. I agree with Rik - XHTML is NOT well supported
by browsers and should not be used unless it is required for some reason.

What can you say when even W3C doesn't recommend it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 28/02/2008, 17h37   #12
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> Just because the validator doesn't catch all errors doesn't mean you
These are NOT errors but valid SGML. They are just not valid XML in
contrast to the part of HTML that is widely known.
  Réponse avec citation
Vieux 28/02/2008, 17h39   #13
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> Only if you use a schema validator. The W3 validator is SGML-based,
> which is not appropriate for validating X(HT)ML.

No. But it is appropriate to validate HTML. Because HTML is SGML.
Thats what I said: HTML supports much more than you want to use. But if
you want to use a subset, use the official one, that is based on XML: XHTML.
  Réponse avec citation
Vieux 28/02/2008, 18h17   #14
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jonas Werres wrote:
>> Just because the validator doesn't catch all errors doesn't mean you

> These are NOT errors but valid SGML. They are just not valid XML in
> contrast to the part of HTML that is widely known.
>


If they're not errors, then what's the problem?

And browsers do understand that a lot better than they do XHTML.

But you also ignore the rest of my points. How convenient.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 28/02/2008, 20h11   #15
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jonas Werres wrote:
>> If they're not errors, then what's the problem?

> The problem is the one I mentionend before and you asked for: Nobody
> will write that on purpose.
>
>> And browsers do understand that a lot better than they do XHTML.

> Do you have an example? The only issue I know is the MIME-type thing
> with IE.
>


Google for xhmtl and "internet explorer". You'll find all kinds of
stuff about it.

>> But you also ignore the rest of my points. How convenient.

> Ok, what was there? The W3C. Yes, I ignored that. After a look into the
> source of http://www.w3.org/.
>


So? They're the ones setting the recommendations. That's what most of
the rest of us follow - including the browser developers. And if they
say XHTML isn't going anywhere soon, browser developers won't be
spending a lot of time supporting it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 28/02/2008, 20h14   #16
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> If they're not errors, then what's the problem?
The problem is the one I mentionend before and you asked for: Nobody
will write that on purpose.

> And browsers do understand that a lot better than they do XHTML.

Do you have an example? The only issue I know is the MIME-type thing
with IE.

> But you also ignore the rest of my points. How convenient.

Ok, what was there? The W3C. Yes, I ignored that. After a look into the
source of http://www.w3.org/.
  Réponse avec citation
Vieux 28/02/2008, 20h29   #17
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Dikkie Dik wrote:

> Not entirely. The best way to send the character set is _outside_ the
> document itself. It is a strange that you should parse the character set
> used out of the encoded document. What about utf-16? or utf-32? Could
> you parse those character sets as easily out of a documented that is
> written in it? Off course not. And if you can, there is no reason to do
> so anymore.
>
> So character sets are sent in a header. PHP supports this in two ways:
> - set the default document type and character set in your PHP.ini,
> - send a header your self with the header() function;
>


that's interesting, having never thought much about charsets. So
if I were ever to need to publish a page that included unusual
(non Latin-1) characters, I could specify the appropriate
alternate encoding via php's header(), and then that particular
page would show the unusual characters correctly. That seems
obvious in retrospect.

I took a brief tour of the web now and see that some Chinese
sites have their own charset (which is included in FF), but Korea
and Thailand did not. Also, Denmark did not. They all used UTF-8.
Is there any overriding principle that determines whether they
use UTF-8 or not? Or is it just case by case?
  Réponse avec citation
Vieux 28/02/2008, 20h34   #18
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jonas Werres wrote:
>> Only if you use a schema validator. The W3 validator is SGML-based,
>> which is not appropriate for validating X(HT)ML.


do online validators sell/give URLs to google, etc?
  Réponse avec citation
Vieux 28/02/2008, 20h58   #19
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jerry schrieb:
> Jonas Werres wrote:
>>> Only if you use a schema validator. The W3 validator is SGML-based,
>>> which is not appropriate for validating X(HT)ML.

>
> do online validators sell/give URLs to google, etc?


No idea, but I don't think, the W3C one does that.
Why do you ask?
  Réponse avec citation
Vieux 28/02/2008, 21h01   #20
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> So? They're the ones setting the recommendations. That's what most of
> the rest of us follow - including the browser developers. And if they
> say XHTML isn't going anywhere soon, browser developers won't be
> spending a lot of time supporting it.


Did you have a look at their website?
  Réponse avec citation
Vieux 29/02/2008, 00h59   #21
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jonas Werres wrote:
>> So? They're the ones setting the recommendations. That's what most
>> of the rest of us follow - including the browser developers. And if
>> they say XHTML isn't going anywhere soon, browser developers won't be
>> spending a lot of time supporting it.

>
> Did you have a look at their website?
>


Sure. I go there regularly. So what?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 29/02/2008, 01h00   #22
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Tony wrote:
> Jerry Stuckle wrote:
>>
>> What can you say when even W3C doesn't recommend it?
>>

>
> I would be very interested in where the W3C says that - I haven't been
> able to find anything like that. Most of the info I'm able to find seems
> to point the other way - such as:
> http://www.webstandards.org/learn/ar...skw3c/oct2003/
> Of course, that's over 4 years old - and that's also the case with the
> info that I find...
>


That's right - it's over 4 years old. Check the www.w3c.org site. I
don't have the link handy, but they are now pushing towards HTML 5.0
instead of a new version of XHTML.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 29/02/2008, 01h19   #23
Tony
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

Jerry Stuckle wrote:
>
> What can you say when even W3C doesn't recommend it?
>


I would be very interested in where the W3C says that - I haven't been
able to find anything like that. Most of the info I'm able to find seems
to point the other way - such as:
http://www.webstandards.org/learn/ar...skw3c/oct2003/
Of course, that's over 4 years old - and that's also the case with the
info that I find...
  Réponse avec citation
Vieux 29/02/2008, 09h22   #24
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> Sure. I go there regularly. So what?
>

It is XHTML? So obviously at least they do not recommend NOT to use it.
  Réponse avec citation
Vieux 29/02/2008, 09h24   #25
Jonas Werres
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOCTYPE

> That's right - it's over 4 years old. Check the www.w3c.org site. I
> don't have the link handy, but they are now pushing towards HTML 5.0
> instead of a new version of XHTML.


Yeah ... HTML 5... Already had a look at THAT?
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h27.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,32009 seconds with 33 queries