473,770 Members | 6,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

serving xhtml with php

Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?

Jul 18 '06 #1
30 2274


ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?
Is it your server? turn off short_tags in your php conf. that way you
can only use <?php not <?

Flamer.

Jul 18 '06 #2

ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?
echo '<?xml ... ?' . '>';

Jul 18 '06 #3
ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?
Perhaps
<?php
.......
?>
<?xml version="1.0" encoding="iso-8859-1"?>

Louise
Jul 18 '06 #4
Chung Leong wrote:
ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?

echo '<?xml ... ?' . '>';
Wait a minute. That's not supposed to be necessary. PHP knows when it's
inside a string.

Jul 18 '06 #5
Rik
Chung Leong wrote:
Chung Leong wrote:
>ab**********@ya hoo.com wrote:
>>If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.
Any way around this?

echo '<?xml ... ?' . '>';

Wait a minute. That's not supposed to be necessary. PHP knows when
it's inside a string.

You are right.
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
Works perfectly here (tested with shorttags on which are usually off).

Grtz,
--
Rik Wasmus

Jul 18 '06 #6

ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?
First you must be certain that your server is set up to deliver true
xhtml. If you use the extension .html you just serve the page as
ordinary html and there is no point in writing the code in xhtml. If
you associate an extension such as .xhtml with the mime type for
xhtml+xml, then you may serve true xhtml using this extension. Then of
course the page can not be viewed by IE6 or IE7, because these outmoded
browsers can not handle true xhtml after all of these years. However
the recent Mozilla family(Firefox, Mozilla, Netscape) and Opera
browsers can handle true xhtml.

Now to your question assuming you are serving true xhtml. See my
example php page at http://www.cwdjr.info/test/PHPxhtml.php . It will
of course not work on IE6 or 7 because it is written and served as true
xhtml 1.1. The secret is that everything above the head tag is written
using php. If a Usenet post properly displays this, the php code used
at the very top of the page to do this is:

<?php
$charset = "iso-8859-1";
$mime = "applicatio n/xhtml+xml";
$prolog_type = "<?xml version=\"1.0\" encoding=\"$cha rset\"
?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">\ n<html
xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >\n";
header("Content-Type: $mime;charset=$ charset");
header("Vary: Accept");
print $prolog_type;
?>

So I guess you could say that you are using php to solve any possible
php problem. There likely are other ways to do this. This is just the
first way that came to mind since I have used something much like this
before. A very simple php code is used to obtain the time display. If
you have the WMP installed, a button to start a .wma music file appears
at the bottom. The page validates as xhtml 1.1 and css at the W3C, and
if you use the extended interface there you will find that it is being
served with the correct mime type for xhtml.

Jul 19 '06 #7
"cwdjrxyz" <sp*******@cwdj r.infowrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
If
you associate an extension such as .xhtml with the mime type for
xhtml+xml, then you may serve true xhtml using this extension. Then of
course the page can not be viewed by IE6 or IE7, because these outmoded
browsers can not handle true xhtml after all of these years.
Really? Are you talking about IE7 for sure now? It's not even out yet and
you claim it's "outmoded" and can't handle xml "after all these years"? Did
you mean IE5?

I found a pretty decent article that explains the situation with IE7 and
xhtml: http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx I recommend
reading it.

Personally I think it's good that the IE people won't even try implementing
something as strict as xml on a buggy and loose parser that IE has always
had. I got the picture from Wilson's article that they're gonna start from
scratch after IE7 and make finally something worthy of the xml parser, not
just (try to) fix quick-and-dirty the current html parser.

Bottom line is that IE sucks more than anything that has ever sucked before,
and it will remain like that all eternity, but there's a chance 7 won't suck
just as much 6 does.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Jul 19 '06 #8
It shouldn't need the line:
<?xml version="1.0" encoding="iso-8859-1"?>
for it to validate as XHTML (I think its just recommended).

You could just omit it if your server/php config won't let you include
it.

ab**********@ya hoo.com wrote:
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
'; ?>
is displayed in the browser.

Any way around this?
Jul 19 '06 #9
Noodle wrote:
It shouldn't need the line:
<?xml version="1.0" encoding="iso-8859-1"?>
for it to validate as XHTML (I think its just recommended).

You could just omit it if your server/php config won't let you include
it.
Yes, that's correct. It /should/ be used, but it's not /necessary/ i.e.
normative. So you can just omit it, your pages will validate anyway.
Moreover, some browsers fall in quirks mode if you add it: check
http://www.quirksmode.org for more specific infos.

(As we say in sicily) Baciamo le mani
--
Massimo "unwiredbra in" Lombardo

Jul 19 '06 #10

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

Similar topics

1
1905
by: cwdjrxyz | last post by:
I am now writing many new pages in xhtml 1.1. They are served as true xhtml by setting the mime type of the server to application/xhtml+xml for the .xhtml extension. Since IE6 and some earlier browsers can not handle this mime type, a simple php include is at the very top of such pages. If the mentioned mime type support for the viewing browser is detected, everything above the head tag of the page is written in xhtml 1.1 code. If the...
15
4356
by: Zhang Weiwu | last post by:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml webpage to IE as application/xml I used that trick and now every one of my xhtml webpage have following first 4 starting lines: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="curseIE.xsl"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
9
1360
by: -Lost | last post by:
In Firefox and Safari for example, if I serve my XHTML documents as application/xml or xhtml+xml they only display the top inch or so of the document. In Opera it says "object has been blocked." In Internet Explorer of course you get total rubbish. Anything from "page cannot be loaded" to "403 no permission." The thing is, I figured the first two at least could handle it, maybe
12
1982
by: -Lost | last post by:
In Firefox and Safari for example, if I serve my XHTML documents as application/xml or xhtml+xml they only display the top inch or so of the document. In Opera it says "object has been blocked." In Internet Explorer of course you get total rubbish. Anything from "page cannot be loaded" to "403 no permission." The thing is, I figured the first two at least could handle it, maybe
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.