Welcome to WebmasterWorld Guest from 54.146.30.44

Forum Moderators: bakedjake

Message Too Old, No Replies

Why does page.php come up blank?

XHTML, XML, PHP issue

     
8:13 pm on Oct 20, 2007 (gmt 0)

New User

5+ Year Member

joined:Oct 20, 2007
posts: 9
votes: 0


I have spent hours trying to figure out why the following page, saved as xhtmlexample.php, comes up blank when viewed in any browser:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page Title</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta http-equiv="Cache-Control" content="max-age=600" />
<meta http-equiv="content-type" content="application/xhtml+xml" />
</head>
<body>
<?php include 'inc_header.php'?>
<h1>Page Heading</h1>
<p>Page Content</p>
<p><?php echo "PHP-generated Content";?></p>
</body>
</html>

This example was taken from the dotMobi Mobile Web Developers Guide, and as far as I can tell, the page should be valid. Perhaps it is a server issue?

Note: If I remove the first line (<?xml ...?>) then it displays just fine and validates on ready.mobi with a 5 rating.

Any ideas?

8:21 pm on Oct 20, 2007 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 31, 2003
posts:9068
votes: 4


Welcome to WebmasterWorld vertex42! Sounds like you have PHP short tags enabled, allowing
<?
as well as
<?php
to delimit PHP code. As such, the XML prolog causes an error.

You should either disactivate short tags, or echo the XML prolog:

<?php echo '<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n';?> 
10:06 pm on Oct 20, 2007 (gmt 0)

New User

5+ Year Member

joined:Oct 20, 2007
posts: 9
votes: 0


Thank you! That worked, except that I used
<?php echo '<?xml version="1.0" encoding="UTF-8"?>';?>

This was certainly worth the $149 subscription.