Php V. Xhtml/xml

admin

Administrator
Staff member
Hello out there all you TCH folk! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> <br /><br />I've got a basic PHP question. Does anyone know of any conflicts between PHP and XML or XHTML? I'm trying to update my web site to be XHTML compliant and I've discovered a problem.<br /><br />Here is the basic skeleton of one of my web pages. I've removed non-essential fluff (e.g., graphics, extra text, etc.) to make it easier to read. Even this simplified page will not display on my browser. All I see is a blank, white screen.<br /><br /><!--fonto:Courier--><span style="font-family:Courier"><!--/fonto--><br /><?xml version="1.0" encoding="UTF-8"?><br /><!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br /><head><br /><title>Testing PHP inside XHTML</title><br /></head><br /><br /><body><br /><p>Here is the clock -- <br /><?php<br />echo( date("g:i a") );<br />echo(",&nbsp;&nbsp;&nbsp;");<br />echo( date("d-M-Y") );<br />?><br /></p><br /></body><br /></html><!--fontc--></span><!--/fontc--><br /><br />Can anyone tell me why this code will not run? I've tried various versions of the code, including removing the <?xml ...> line and the xmlns="http://... " statement from the document. Even removing these two items doesn't help. In fact, the only way I can get this page to display at all is to code it like this.<br /><br /><!--fonto:Courier--><span style="font-family:Courier"><!--/fonto--><br /><html><br /><head><br /><title>Testing PHP inside XHTML</title><br /></head><br /><br /><body><br /><p><br />Here is the clock -- <br /><?php<br />echo( date("g:i a") );<br />echo(",&nbsp;&nbsp;&nbsp;");<br />echo( date("d-M-Y") );<br />?><br /></p><br /></body><br /></html><!--fontc--></span><!--/fontc--><br /><br />I know there has to be some way to run PHP language inside an XHTML document, but I just don't know how to do it. Can someone help me out?<br /><br />Thanks!<br />Kasey<!--content-->
I know this is a silly question but... does the file have a .php extension? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /><!--content-->
Hiya TCH-Raul <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />Yes, the file does have a .php extension. I didn't clearly state that ... sorry for the confusion!<br /><br />Kasey<!--content-->
Have you tried it with the <!doctype> tag first, then the <?xml> tag, then your <html> tag? I thought the doctype came first, but maybe it doesn't matter... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> <br /><br />Kris<!--content-->
Sorry, ignore my previous post, but read this one....<br /><br /><a href="http://forums.devshed.com/archive/5/2001/10/4/24769" target="_blank">http://forums.devshed.com/archive/5/2001/10/4/24769</a><br /><br />Could this be part of the problem? Or is our php.ini file already configured this way? I noticed on one of the TCH pages it said we could not edit the php.ini... <br /><br />Hope this helps somewhat. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />Kris<!--content-->
Well, I never heard of the <?xml ....> declaration messing up PHP, even with short tags on... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br />PHP should be looking *just* for <? or <?php, not <?somethingelse.<br />But give it a try, remove the <?xml ...> declaration from the top of the file. I'm not sure it will work but you never know...<!--content-->
Not sure if this will help, but I copied and pasted your code into two different files and posted them both here:<br /><br /><a href="http://wigoweb.com/test/" target="_blank">http://wigoweb.com/test/</a><br /><br />You can try them. They both display the following text:<br /><br />Here is the clock -- <br /><br />Neither one actually displays any of the php you have listed. However, that may be due to my just getting started with php and probably not having it all set up correctly yet.<br /><br />But, I did not get a blank white page for either of the two files you provided.<!--content-->
I think the very top <?xml line is the one to change. The following code works for me:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><title>Testing PHP inside XHTML</title><br /></head><br /><br /><body><br /><p>Here is the clock --<br /><?php<br />echo( date("g:i a") );<br />echo(",&nbsp;&nbsp;&nbsp;");<br />echo( date("d-M-Y") );<br />?><br /></p><br /></body><br /></html><!--c2--></div><!--ec2--><br /><br /><a href="http://www.rangecall.com/test2.php" target="_blank">Here's a link to the working page.</a><!--content-->
<!--fonto:Verdana--><span style="font-family:Verdana"><!--/fonto--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#555555--><span style="color:#555555"><!--/coloro--><br /><br />I'll have to implement that across my site. I've noticed that in my (minimal-use-of) php pages, all I could have was the doctype. No <b><?xml version=...</b> and no <b><html xmlns="http://www.w3.org/1999/xhtml"></b>. I figured that as long as my pages validated, that they were ok. But if I can add them back in, then cool :Nerd: <br /><br />later,<br />!!blue<br /><!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--fontc--></span><!--/fontc--><!--content-->
Tracy is right, that's the solution for the problem. I've used it countless times but my brain was probably on vacation, since I didn't remember it <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /><!--content-->
Nice job Tracy!<!--content-->
Thanks, Robert...but I owe that one to DWMX! It showed me the answer.<!--content-->
<img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> I want to say thank you to everyone for spending so much time helping me with this code. Big thanks to Tracy -- your suggestion fit the bill. The code runs -- yaaaay!<br /><br />So what was the deal with this? Is it conflicting processors (e.g., PHP processor trying to run an XML directive?) I hadn't heard of that before, but I guess if they both use the same <? symbol to declare the start of a sequence of code to be processed, then that would make sense.<br /><br />Thanks again everyone!<br />Kasey<br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /><!--content-->
Watch out Big Boys, Tracy's makin' a name for herself! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /><!--content-->
I'm currently unemployed (by my own will)...so I figure I ought to do something valuable with my time!!!! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/goof.gif" style="vertical-align:middle" emoid=":goof:" border="0" alt="goof.gif" /> Nevermind the 3 or so websites waiting patiently for me to tend them... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /><!--content-->
 
Back
Top