Welcome to WebmasterWorld Guest from 54.159.12.17

Forum Moderators: bakedjake

Message Too Old, No Replies

Why does page.php come up blank?

XHTML, XML, PHP issue

     

vertex42

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

5+ Year Member



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?

encyclo

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

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



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';?> 

vertex42

10:06 pm on Oct 20, 2007 (gmt 0)

5+ Year Member



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

This was certainly worth the $149 subscription.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month