niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » PHP
serving xhtml with php
Post new topic   Reply to topic Page 1 of 2 [24 Posts] View previous topic :: View next topic
Goto page:  1, 2 Next
Author Message
flamer
*nix forums beginner


Joined: 06 Jul 2006
Posts: 36

PostPosted: Tue Jul 18, 2006 11:20 pm    Post subject: Re: serving xhtml with php Reply with quote

abracad_1999@yahoo.com wrote:

Quote:
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.
Back to top
chernyshevsky@hotmail.com
*nix forums Guru


Joined: 09 Mar 2005
Posts: 871

PostPosted: Tue Jul 18, 2006 11:31 pm    Post subject: Re: serving xhtml with php Reply with quote

abracad_1999@yahoo.com wrote:
Quote:
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 ... ?' . '>';
Back to top
chernyshevsky@hotmail.com
*nix forums Guru


Joined: 09 Mar 2005
Posts: 871

PostPosted: Tue Jul 18, 2006 11:47 pm    Post subject: Re: serving xhtml with php Reply with quote

Chung Leong wrote:
Quote:
abracad_1999@yahoo.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.
Back to top
boclair
*nix forums beginner


Joined: 10 Mar 2005
Posts: 17

PostPosted: Tue Jul 18, 2006 11:49 pm    Post subject: Re: serving xhtml with php Reply with quote

abracad_1999@yahoo.com wrote:
Quote:
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
Back to top
Rik
*nix forums Guru Wannabe


Joined: 16 Nov 2005
Posts: 291

PostPosted: Tue Jul 18, 2006 11:58 pm    Post subject: Re: serving xhtml with php Reply with quote

Chung Leong wrote:
Quote:
Chung Leong wrote:
abracad_1999@yahoo.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
Back to top
cwdjrxyz
*nix forums beginner


Joined: 19 Jul 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 1:53 am    Post subject: Re: serving xhtml with php Reply with quote

abracad_1999@yahoo.com wrote:
Quote:
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 = "application/xhtml+xml";
$prolog_type = "<?xml version=\"1.0\" encoding=\"$charset\"
?>\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.
Back to top
Kimmo Laine
*nix forums Guru Wannabe


Joined: 25 Mar 2005
Posts: 209

PostPosted: Wed Jul 19, 2006 7:34 am    Post subject: Re: serving xhtml with php Reply with quote

"cwdjrxyz" <spamtrap1@cwdjr.info> wrote in message
news:1153274022.331966.293190@p79g2000cwp.googlegroups.com...
If
Quote:
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
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
Back to top
Noodle
*nix forums beginner


Joined: 04 Jul 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 8:03 am    Post subject: Re: serving xhtml with php Reply with quote

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.



abracad_1999@yahoo.com wrote:
Quote:
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?
Back to top
unwiredbrain@gmail.com
*nix forums beginner


Joined: 12 Jun 2006
Posts: 5

PostPosted: Wed Jul 19, 2006 10:07 am    Post subject: Re: serving xhtml with php Reply with quote

Noodle wrote:
Quote:
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 "unwiredbrain" Lombardo
Back to top
cwdjrxyz
*nix forums beginner


Joined: 19 Jul 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 3:56 pm    Post subject: Re: serving xhtml with php Reply with quote

Kimmo Laine wrote:
Quote:
"cwdjrxyz" <spamtrap1@cwdjr.info> wrote in message
news:1153274022.331966.293190@p79g2000cwp.googlegroups.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 said true xhtml rather than xml as you see from your quote above. You
could also include IE5 and all lower IEs if you wish but it hardly
would seem necessary if the IE6 does not support true xhtml. The
article quoted just below and many other reports confirm that IE7 will
not support true xhtml based on the mime type application/xhtml+xml. Of
course there could be a last minute change, but considering that the
browser would require extreme rewriting, this seem to be highly
unlikely unless the introduction of the IE7 id delayed for many months
and Microsoft perhaps hires some people away from Mozilla and Opera who
have experience in introduction of true xhtml.

Quote:
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.
Back to top
chernyshevsky@hotmail.com
*nix forums Guru


Joined: 09 Mar 2005
Posts: 871

PostPosted: Wed Jul 19, 2006 4:02 pm    Post subject: Re: serving xhtml with php Reply with quote

What is the point of XHTML anyway? To me it always seems an exercise in
vanity. I was looking at the FAQ at the W3C and the answer to the
question as to why XHTML is necessary goes something like "Well, we had
this workshop a few years ago and everyone there thought it's a good
idea."
Back to top
cwdjrxyz
*nix forums beginner


Joined: 19 Jul 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 4:26 pm    Post subject: Re: serving xhtml with php Reply with quote

Chung Leong wrote:
Quote:
What is the point of XHTML anyway? To me it always seems an exercise in
vanity. I was looking at the FAQ at the W3C and the answer to the
question as to why XHTML is necessary goes something like "Well, we had
this workshop a few years ago and everyone there thought it's a good
idea."

Of course one is still free to write code in an html level as low as
3.2 which still can be validated at the w3c and which seems to be
supported by most recent computer browsers also. The importance of
xhtml/xml is that a very large number of smaller devices now support
xml and sometimes not html. Thus traditional computer browsers need to
be brought in line to allow easy exchange of data between many
different types of devices. If I were teaching a programming course, I
would require that all programs be written in xhtml 1.1 as well as html
4.01 strict or be given a reason of why a program can not be written
in xhtml 1.1. I would also give any program that did not completely
validate at the w3c html/xhtml and css validators a grade of zero.
Fortunately for many future students, I am very unlikely to ever teach
programming Smile .
Back to top
Geoff Berrow
*nix forums Guru


Joined: 19 Feb 2005
Posts: 491

PostPosted: Wed Jul 19, 2006 4:34 pm    Post subject: Re: serving xhtml with php Reply with quote

Message-ID: <1153326410.946395.313070@h48g2000cwc.googlegroups.com> from
cwdjrxyz contained the following:

Quote:
If I were teaching a programming course, I
would require that all programs be written in xhtml 1.1 as well as html
4.01 strict

Why both? They are two separate things used for different reasons.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Back to top
chernyshevsky@hotmail.com
*nix forums Guru


Joined: 09 Mar 2005
Posts: 871

PostPosted: Wed Jul 19, 2006 6:18 pm    Post subject: Re: serving xhtml with php Reply with quote

cwdjrxyz wrote:
Quote:
Of course one is still free to write code in an html level as low as
3.2 which still can be validated at the w3c and which seems to be
supported by most recent computer browsers also. The importance of
xhtml/xml is that a very large number of smaller devices now support
xml and sometimes not html. Thus traditional computer browsers need to
be brought in line to allow easy exchange of data between many
different types of devices.

I'm a believer in democracy and the free market. The idea that we
should all adopt a technology because a bunch of guys in a room think
it's a good thing offends me.

Having the whole world adjust to the limitation of a few devices is a
preposterous misallocation of human resource. If some devices can't
handle HTML, screw them. People will buy competing products that can.
Back to top
cwdjrxyz
*nix forums beginner


Joined: 19 Jul 2006
Posts: 4

PostPosted: Wed Jul 19, 2006 6:27 pm    Post subject: Re: serving xhtml with php Reply with quote

Geoff Berrow wrote:
Quote:
Message-ID: <1153326410.946395.313070@h48g2000cwc.googlegroups.com> from
cwdjrxyz contained the following:

If I were teaching a programming course, I
would require that all programs be written in xhtml 1.1 as well as html
4.01 strict

My complete statement was:

"If I were teaching a programming course, I
would require that all programs be written in xhtml 1.1 as well as html
4.01 strict or be given a reason of why a program can not be written
in xhtml 1.1."

Quote:
Why both? They are two separate things used for different reasons.

An xhtml program can be pure html, pure xml, or a combination of both.
Thus an xhtml program that has no xml only functions in some cases is
about the same as an html 4.01 strict program with the addition of a
few special things, such as closing everything, using lower case
characters only, etc. In that case the html 4.01 strict page works just
as well and does not require a special version for IE. However some
xhtml pages may contain xml content that is best handled by xhtml, or
in some cases xml only. Thus I needed an exception and would require
the reason for the exception to see if it was understood why the
exception was necessary, or far more practical. I should also have
included the inverse case when the xhtml page can not be written as
html 4.01 strict without undue complication, often because of the xml
content in the xhtml page.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 2 [24 Posts] Goto page:  1, 2 Next
View previous topic :: View next topic
The time now is Fri Nov 21, 2008 10:34 pm | All times are GMT
navigation Forum index » Programming » PHP
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts xhtml generation library Mitchel Haas C++ 0 Tue Jun 27, 2006 3:54 am
No new posts serving request only when http -X (debug mode 1 worker) Meir Yanovich Apache 5 Thu Jun 08, 2006 7:42 am
No new posts Dumb-as-rocks WSGI serving using standard library Ben Finney python 2 Mon May 22, 2006 8:18 am
No new posts Problem - Serving web pages on the desktop (SimpleHTTPSer... Ben python 1 Tue May 09, 2006 6:06 am
No new posts Problem - Serving web pages on the desktop (SimpleHTTPSer... test@test.test python 0 Tue May 09, 2006 5:54 am

Insurance | Loans | Mortgages | Unsecured Loans | Dutch Bodybuilding Forums
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3852s ][ Queries: 16 (0.2525s) ][ GZIP on - Debug on ]