473,506 Members | 11,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dreamweaver, PHP and XHTML compliance

Hi

I'm essentially a back-end programmer so I don't know very much about
Dreamweaver. However, I work with web-designers who are keen for me to
write my pages using Dreamweaver templates.

One problem that has emerged straight away is that of XHTML compliance. I
understand (and please correct me if I'm wrong) that in order to achieve
this, every document must start with a line like:

<?xml version="1.0" encoding="iso-8859-1"?>

However, this won't work in PHP, because as soon as it sees the '<?' it
assumes that what follows is php code (and crashes).

It's simple enough to add the line:

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>

at the top of your PHP pages, but then it won't work in plain HTML, so it
can't go in the template. What we need is version 1 of the line in HTML
docs and version 2 in PHP docs.

Does anyone know the answer to this problem?

Jul 17 '05 #1
3 2079
On Mon, 13 Dec 2004 13:33:47 GMT, "Captain Nemo"
<Ca*****@NoSpam.com> wrote:
One problem that has emerged straight away is that of XHTML compliance. I
understand (and please correct me if I'm wrong) that in order to achieve
this, every document must start with a line like:

<?xml version="1.0" encoding="iso-8859-1"?>

However, this won't work in PHP, because as soon as it sees the '<?' it
assumes that what follows is php code (and crashes).
[...]
Does anyone know the answer to this problem?


From what I understand, you only need to use an XML declaration if
you're serving your XHTML page as XML. Since browsers still have a
problem with that, most people serve it as text/html. So you don't
need that opening bit, and will still be standards compliant.
Here's further reading from the W3C:

http://www.w3.org/International/tuto...enc/#declaring

Ian
--
http://www.sundry.ws/
http://www.bookstacks.org/
Jul 17 '05 #2
.oO(Captain Nemo)
I'm essentially a back-end programmer so I don't know very much about
Dreamweaver. However, I work with web-designers who are keen for me to
write my pages using Dreamweaver templates.

One problem that has emerged straight away is that of XHTML compliance. I
understand (and please correct me if I'm wrong) that in order to achieve
this, every document must start with a line like:

<?xml version="1.0" encoding="iso-8859-1"?>
Nope. While the XML prolog is recommended, it's not always necessary.
It's used to specify the used encoding, but this can/should also be done
in the response header sent by the server (with a charset parameter in
the content-type header). Additionally using such a prolog will kick
Internet Explorer into quirks mode.
However, this won't work in PHP, because as soon as it sees the '<?' it
assumes that what follows is php code (and crashes).
That's because short_open_tags are enabled on the server.
It's simple enough to add the line:

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>
Ugly.

I would rather turn short_open_tags off (along with register_globals and
magic_quotes_gpc).
at the top of your PHP pages, but then it won't work in plain HTML, so it
can't go in the template. What we need is version 1 of the line in HTML
docs and version 2 in PHP docs.

Does anyone know the answer to this problem?


First you should ask the designers why they insist on using XHTML.
HTML 4.01 Strict is more than enough in most cases unless you know
exactly what you're doing. Currently there's little to no reason to use
XHTML. Only the most recent browsers like Opera and Mozilla really
support it, for others like IE you have to deliver it as text/html,
which makes no sense at all and may cause new problems.

Sending XHTML as text/html Considered Harmful
http://hixie.ch/advocacy/xhtml

Micha
Jul 17 '05 #3
Captain Nemo wrote:
However, this won't work in PHP, because as soon as it sees the '<?' it
assumes that what follows is php code (and crashes).

It's simple enough to add the line:

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?>

at the top of your PHP pages, but then it won't work in plain HTML, so it
can't go in the template. What we need is version 1 of the line in HTML
docs and version 2 in PHP docs.

Does anyone know the answer to this problem?


You could try "short_open_tag = off"
http://www.php.net/manual/en/ini.sec...short-open-tag

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

119
4509
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.