Welcome to WebmasterWorld Guest from 54.162.19.123

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

XHTML and PHP

     
1:10 am on Jul 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


I need a little help, I am working on a site that will have PHP and XHHTML both.

I am having a problem including this line though:
<?xml version="1.0" encoding="UTF-8"?>

Any ideas how to pharse this? Or am I just doing it wrong?

4:49 am on July 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 9, 2001
posts:416
votes: 0


Knowles, have a look at the NYPL styleguide [nypl.org] for XHTML doc type and character encoding.

"Note: many XHTML pages begin with an optional XML prologue ( <?xml> ) that precedes the DOCTYPE and namespace declarations. Unfortunately, this XML prologue causes problems in many browsers..."

6:30 am on July 18, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


No, I beleive Knowlse is getting a parse error right? Here ya go....

print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

Nick

1:01 pm on July 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


Thank you Nick Ill try it when I get home, I think I tried echo'in it but that still gave an error.

toadhall, I know of the errors caused my user base is newer browsers, I have tested all my websites with that encoding and it works on all mine (IE Opera Mozilla).

4:33 pm on July 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 9, 2001
posts:416
votes: 0


Best to encode the angle brackets:

print("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;");

4:49 pm on July 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


Good idea toadhall, thanks for the suggestion!
6:44 pm on July 18, 2002 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8471
votes: 222


Knowles,

I use PHP and XHTML 1.0 strict. I do this:

<?php echo '<?xml version="1.0" encoding="iso-8859-1"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


print("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;");

Toadhall is wrong about this. You *want* the brackets. If you do not use bracks, but instead use &lt; it will not recognize your xml tag as a tag, but as text and you don't want that.

Incidentally, I had trouble with Unicode and validation (because I don't have an editor that doesn't add the .... what is it? BMsomething and W3C chokes on validation. What have you done?

Tom

11:31 pm on July 18, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


I have been editing with homesite 5.01 its been giving me no problems validating my XHMTL code, check the link in my interests (soon as I add it)

<added>Its not PHP but I havent gotten far enough in development to do that</added>

<addeded> WOO HOO Mayed Preferred Member </addeded>

12:19 am on July 19, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0



Parse error: parse error in localhostinfo/site.php on line 1

Doesnt matter which way I try echo or print, ' or " it still comes out with a parse error.
1:58 am on July 19, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:June 3, 2002
posts:169
votes: 0


Seems like you got it working. Which way did you code it?
2:47 am on July 19, 2002 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8471
votes: 222


Knowles,

I don't understand. The site you listed looks perfect and you say the problem is not with your XHTML.

Then you say it isn't with PHP either, but you get a parse error, so that can only be PHP.

The PHP code that I posted works fine and generates valid XHTML. If you are getting a parse error, it's coming from somewhere else.

Try creating "skeleton" pages that just call stub functions (routines that just return without doing anything). Get rid of complexity until you locate the problem. If you still can't figure it out, post the code.

Tom

2:50 am on July 19, 2002 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8471
votes: 222


Can you post the first 5 lines of site.php?

If I had to guess, upon thinking about it, I bet you're missing a semicolon after line 1 or something like that.

Tom

11:52 am on July 19, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


Sorry for the confusion, the one I put in intrests is Pure XHTML no PHP. I am working locally to turn it to PHP.
First 5 lines:

<?PHP print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>

Also tried:
<?PHP echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

The reason for the URL in Profile was in reference to this

Incidentally, I had trouble with Unicode and validation (because I don't have an editor that doesn't add the .... what is it? BMsomething and W3C chokes on validation. What have you done?
That was an example of Unicode and validated code.
7:18 pm on July 19, 2002 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8471
votes: 222



<?PHP print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>

1. Your parentheses don't match.

2. I'm not certain, but the standard is <?php. I'm not sure whether or not uppercase is allowed, though it would take two seconds to test (but I'm too lazy).


Also tried
<?PHP echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

That is exactly what I have, except for lowercase tags for invoking php, and it validates.

Tom

8:08 pm on July 19, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


Thank you for the catch on the missed quote. DOH! And now on the server the echo way is working but it wasnt on localhost, Ill have to play with it this weekend to figure out whats wrong with me!

Thanks for yalls help.

9:55 pm on July 19, 2002 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8471
votes: 222


You should get an editor that has decent pair matching for [{('".

Syntax highlighting, code completion, all that sort of stuff is just eye candy. It can make things easier to read, but it doesn't help much in the end. Brace matching is such a help when your eyes just won't work. There are a lot of editors that support it.

- I've once had emacs set up for it (just parens for Scheme programming)

- I mostly use HAPedit, which does it pretty nicely, but I'm sort of biased there because I'm the one who made the feature request and so it's sort of done to the way I like it.

- I think TextPad, EditPad and UltraEdit can all do this, but I don't use them so I don't know.

Cheers,

Tom

11:14 pm on July 19, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 17, 2002
posts:601
votes: 0


Yes I have played with some in the past that had this function and it is very helpful, I am not sure it would have fixed the issue for me though I was not even looking at that! DUH!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members