Jump to content

Recommended Posts

I set up a guestbook in php but it of course does work with the html doc type declaration I use for the other html pages since it confuses the browser. So I deleted the xml and doc type but when I try to validate I get lots of errors for this page. Is there a way around this? I read somewhere online that you can use javascript to get around this, but I tried using a <script> document.write(); and that didn't work.

 

I am currently using the transitional doctype in the rest of my pages:

<?xml version="1.0" encoding="UTF-8"?>

<!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">

 

I also noticed that when I load the same php page in IE 7/8, the php page is not centered (like the rest of my pages) and some of my other css properties are not being accessed (though not all which is wierd). I've still got the external link to the css file in the header, so I suspect it has to do with the doctype missing, but maybe it is just IE :P Anyone know how to resolve this?

1. The doctype isn't affected by PHP, unless you are doing something strange in the PHP - why can't you just use the same doctype as everywhere else on your site.

 

2. Your page breaking in IE 7/8 is a problem with IE (most likely) not PHP, maybe your CSS needs some tweaking.

What issues are your facing when adding those lines to your script?

 

Also in order for browsers to apply your CSS properly you need to provide a doctype. Otherwise you will experience unexpected behaviour.

You most probably have short_open_tag enabled and PHP is trying to parse this as PHP code:

<?xml version="1.0" encoding="UTF-8"?>

In which case you should echo that line to prevent this from happening

<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"; ?>\n"; ?>

thank you very much wildteen88! I am just getting into php - can you please tell me what a short_open_tag enabled means? I see you escaped the quotes with the backslash.

 

FYI - I still got one error with your adjusted echo xml declaration and I figured out it was the extra ";" after \"UTF-8\"; :)

 

bdmovies – wildteen88's fix solved my IE page layout problem

When the setting short_open_tag is enabled it allows you to use short hand syntax such as <? ?> instead of <?php ?> or <?='hello'?> instead of <?php echo 'hello'; ?>

However this setting is now depreciated and is disabled by default. It is always best to use the full PHP syntax as this will allow your code to be more portable.

huh! thanks.

 

my php code in the doc is surrounded by <?php ..... ?> but there are instances where it switches back to html and then uses the short tag when resuming php. Is the short tag enabled an option you code in php or is it a browser preference?

 

thanks very much!!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.