ksassa Posted October 7, 2006 Share Posted October 7, 2006 I have the following html file[code]<?xml version = "1.0" encoding = "utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><!-- apples.html The contents of the apple frame (displayed in second frame of frames.html) of frames.html - a general description of fruit --><html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title> Apple Information </title> </head> <body> <p> Apple is the common name for any tree of the genus Malus, of the family Rosaceae. Apple trees grow in any of the temperate areas of the world. Some apple blossoms are white, but most have stripes or tints of rose. Some apple blossoms are bright red. Apples have a firm and fleshy structure that grows from the blossom. The colors of apples range from green to very dark red. The wood of apple trees is fine-grained and hard. It is, therefore, good for furniture construction. Apple trees have been grown for many centuries. They are propagated by grafting because they do not reproduce themselves. </p> </body></html>[/code]I am also running Apache which I obtained from [url=http://www.apachefriends.org/en/xampp.html]http://www.apachefriends.org/en/xampp.html[/url]. When I open up IE6 and go to http://localhost/apples.html, I find that the html file is displayed like an xml file would be with a listing of all the html tags and content. But if I take out the xml declaration, IE6 displays the html file properly. I also discovered that if I leave the xml declaration in and take out the comment or make it very short, then IE6 displays the html file properly. In addition, if I open up Windows Explorer and navigate to where apples.html is located on my hard drive and double click on it, the html file is displayed properly by IE. Moreover, I find that Mozilla Firefox displays it properly all the time. Does any one know why this is happeneing? Is the xml declaration causing problems? Quote Link to comment Share on other sites More sharing options...
rochakchauhan Posted September 7, 2008 Share Posted September 7, 2008 I believe you are saving the above file and .php. If thats the case you need to write the code this this:[code]<?='<?xml version = "1.0" encoding = "utf-8"?>';?><!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"> <head> <title> Apple Information </title> </head> <body> <p> Apple is the common name for any tree of the genus Malus, of the family Rosaceae. Apple trees grow in any of the temperate areas of the world. Some apple blossoms are white, but most have stripes or tints of rose. Some apple blossoms are bright red. Apples have a firm and fleshy structure that grows from the blossom. The colors of apples range from green to very dark red. The wood of apple trees is fine-grained and hard. It is, therefore, good for furniture construction. Apple trees have been grown for many centuries. They are propagated by grafting because they do not reproduce themselves. </p> </body></html>[/code] Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 8, 2008 Share Posted September 8, 2008 What? First of all, NEVER use short tags. Second of all, I have no idea what that would do for him. Quote Link to comment Share on other sites More sharing options...
haku Posted September 8, 2008 Share Posted September 8, 2008 While you are right about not using short tags, he is right about what he said. When echoing out an XML declaration in PHP, PHP thinks the closing xml tag is a closing php tag, and it screws everything up. As a result, escaping the brackets is necessary, though I prefer just to exit out of php altogether, output the xml declaration directly as text, then enter back into php if necessary. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted September 8, 2008 Share Posted September 8, 2008 That is why php6 has completely dropped support for php short tags... ;) Quote Link to comment Share on other sites More sharing options...
haku Posted September 8, 2008 Share Posted September 8, 2008 Good to know. My company just bought a site recently in which the original coder used short tags, and our server doesn't allow them. That means I spent a whole lot of time going through and finding all the short tags and turning them into long tags. Pain in the ass. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 8, 2008 Share Posted September 8, 2008 [quote author=haku link=topic=110761.msg985174#msg985174 date=1220837262]While you are right about not using short tags, he is right about what he said. When echoing out an XML declaration in PHP, PHP thinks the closing xml tag is a closing php tag, and it screws everything up. As a result, escaping the brackets is necessary, though I prefer just to exit out of php altogether, output the xml declaration directly as text, then enter back into php if necessary. [/quote]That's why you turn short tags off. Then you don't have such problems. Quote Link to comment Share on other sites More sharing options...
haku Posted September 8, 2008 Share Posted September 8, 2008 There is no such thing as a closing short tag. PHP closing tags and XML closing tags are identical. Turning off short tags will not solve the problem, the closing xml tag will still close the PHP and cause problems. Which is why the method he posted above solves the problem. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 8, 2008 Share Posted September 8, 2008 [quote author=haku link=topic=110761.msg986001#msg986001 date=1220915908]There is no such thing as a closing short tag. PHP closing tags and XML closing tags are identical. Turning off short tags will not solve the problem, the closing xml tag will still close the PHP and cause problems. Which is why the method he posted above solves the problem.[/quote]Turning off short tags means that the starting <? of the xml declaration won't start a PHP block. Quote Link to comment Share on other sites More sharing options...
haku Posted September 9, 2008 Share Posted September 9, 2008 YPHP has already been started. The XML starting tag doesn't matter, because PHP has already been started. But the ending tag of the XML declaration ends [i]PHP[/i] as well as XML. I don't know where you got this starting tag thing, I never mentioned anything about a starting tag, and no one else did either. However I have mentioned the closing tag a number of times.Whether short tags are on or off, if PHP has been entered, the closing tag of the XML declaration will close the PHP. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 [quote author=haku link=topic=110761.msg986087#msg986087 date=1220923163]YPHP has already been started. The XML starting tag doesn't matter, because PHP has already been started. But the ending tag of the XML declaration ends [i]PHP[/i] as well as XML. I don't know where you got this starting tag thing, I never mentioned anything about a starting tag, and no one else did either. However I have mentioned the closing tag a number of times.Whether short tags are on or off, if PHP has been entered, the closing tag of the XML declaration will close the PHP.[/quote]Wait, I don't even know how this topic got brought up...He wasn't using PHP for the XML tags in the original post. Wth are we talking about? Quote Link to comment Share on other sites More sharing options...
haku Posted September 9, 2008 Share Posted September 9, 2008 It's all there for you to see, but Rochakuchouhan said:[quote]I believe you are saving the above file and .php. If thats the case you need to write the code this this:[/quote]His English was maybe not the best, but he was supposing that the OP was trying to echo out an xml statement using php. You replied in a manner like he didn't know what he was talking about, and I pointed out that he in fact did, as echoing out an XML declaration in PHP can cause problems.As for whether or not the OP was using php or not, he didn't say, but the problems that he described made it appear very likely that he was, and that he was trying to echo out the XML declaration with it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.