...

View Full Version : XHTML has a problem with include scripts?



ssskaya
05-05-2004, 08:52 AM
I plan to update my HTML 4.0.1 scripts to XHTML.

Currently I have been using .php scripts for the header and footer which is something like:

<html>
<body>

<?php include("header.php"); ?>

<table>
Text.
</table>

<?php include("header.php"); ?>

</body>
<html>

But my .php script doesn't show when I convert my script to XHTML which has the doctype as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


Does XHTML have a problem with php includes?

jbot
05-05-2004, 09:57 AM
are you're files saved as PHP files?

ssskaya
05-05-2004, 10:12 AM
yes, the file has a .php extension.

otherwise, my server won't treat them as .php scripts.

why? Can I not do that?

jbot
05-05-2004, 10:14 AM
i'm talking about the main file, not the includes. but, yes, you have to give it an extension of .php.

of course, you have to have PHP installed on the server. you sure you've got that set up. sounds to me like you don't.

jbot
05-05-2004, 10:14 AM
wot's in the include files?

ssskaya
05-05-2004, 11:21 AM
I think I was not clear.

I am ALREADY using PHP. No problems with my server.

What I am trying to do is to update the HTML script to XHTML.

The main file you mention (that has the includes in it) has a .php extention too.

but the script is like I have written above.

jbot
05-05-2004, 11:35 AM
not sure, mate.

seems to me that the HTML being parsed by your PHP includes could be at fault.

if the incs work fine under plain-old HTML, then everything PHP-Apache side is fine, so it must be the actual HTML itself within the incs.

can we see wot the rendered HTML should be like?

ssskaya
05-05-2004, 12:02 PM
I now understood where the problem is, but I am not sure why it happens.

Dreamweaver automatically inserts <?xml version="1.0" encoding="iso-8859-1"?> at the very beginning of the script.

however, php includes do not work with it.

there are no problems when I take it off.

do you know why this happens?

jbot
05-05-2004, 12:07 PM
hmmm, not really otherthan to suggest that it's prolly interfering with your DTD declaration.

i'm not a fan of Dreamweaver. prefer to handcode everything. although wouldn't mind using M7 for JSP editing.

if you're looking for an alternative tool to Dreamweaver for PHP editing, try using Eclipse. You'll need to get a PHP plugin for it, but it's a superb wee IDE, albeit not WYSIWIG. :thumbsup:

Mhtml
05-05-2004, 01:06 PM
This is a PHP question and should be in the PHP forum.

Change it to this --

<?php echo "<"."?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>

brothercake
05-05-2004, 05:02 PM
What's happening is that the XML processing instruction "<?" is being interpreted as a PHP instruction.

What Mhtml posted will work if it's the only way, but the best solution if you can reconfigure PHP is to turn off short open tags, so that you have to go "<?php", and then the XML prolog won't trigger PHP parsing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum