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

05-05-2004, 09: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:


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


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


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?

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

05-05-2004, 11: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?

05-05-2004, 11: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.

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

05-05-2004, 12:21 PM
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.

05-05-2004, 12:35 PM
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?

05-05-2004, 01: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?

05-05-2004, 01: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:

05-05-2004, 02: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\"?".">"; ?>

05-05-2004, 06: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.