Forum Moderators: coopster
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.
<?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>
<?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.