Forum Moderators: coopster

Message Too Old, No Replies

php and XHTML problem

         

secureitall

9:06 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



Hi,

I was having a problem with when I changed a xhtml page into page and following is the error I got


Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwroot\contact2.php

I solved the problem when I removed the following lines from the php page


<?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">
<head>
<title>test php page</title>
..........

and replace with


<html>
<head>
<title>test php page</title>
..........

Can anyone explain to me why this happened?

thxs you.

bcolflesh

9:21 pm on Sep 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps an invalid return character in your DOCTYPE line - was it split in your code the way it's displayed here? Regardless, try adding back the missing material line by line until you can repeat the error - then you'll know where it's choking.

Paul in South Africa

9:22 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



At a guess it would seem that the line

<?xml version="1.0" encoding="iso-8859-1"?>

is being parsed as php. When using PHP and XML you should always make sure that short tags are disabled in your php.ini file. short_open_tag = Off

I think short tags are enabled by default.

<added>Just found the part of the manual [php.net] that refers to this.</added>

copongcopong

3:08 am on Sep 17, 2003 (gmt 0)

10+ Year Member



might as well try to simply echo that part.

echo '<?xml version="1.0" encoding="iso-8859-1"?>';

BergtheRed

4:01 am on Sep 17, 2003 (gmt 0)

10+ Year Member



well FWIW ... this:

<?php

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";
echo "<title>test php page</title>\n";

?>

worked fine for me.

secureitall

11:53 am on Sep 17, 2003 (gmt 0)

10+ Year Member



Thanks for all your helps,

As Paul_in_South_Africa mentioned, it was <? xml...?> was causing the problem.

thxs again :)

ergophobe

9:57 pm on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Related issue.

Yup, for XHTML you should have the <?xml?> The problem is, however, this triggers quirks mode in IE6, so it will follow the incorrect box model for CSS, for example. For the time being, it's better to leave the tag off and just go with the old-fashioned language declaration.

T