• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

html page returns server error on php server

When I open a simple HTML page on Apache, using usbwebserver 7.0 (www.usbwebserver.com)  I get a server error.
One problem seems to be the <?xml version="1.0"encoding="UTF-8"?> line. If I type only the php tag within the simple <html> and <body>  tags there's no server error, as soon as I add the <?xml> tag I get a server error.
Is there a settng I can change in one of the server setting files to make this work?
Setting files are enclosed.


<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>	... </title>
	</head>
	<body>
		<p>
			<?php
			print("hallo PHP wereld!"); 
			?>
		</p>
	</body>
</html>

Open in new window

settings.ini
settings.txt
settings.ini
php.ini
0
ruud00000
Asked:
ruud00000
  • 5
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
<?xml version="1.0"encoding="UTF-8"?> is used for serving up XML documents.  XHTML pages do not use that.  Acceptable DOCTYPES for 'text/html' are listed here:
http://www.w3.org/QA/2002/04/valid-dtd-list.html
0
 
tv0085Commented:
There is a setting in php.ini.
change
short_open_tag = On
to
short_open_tag = Off

; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
0
 
ruud00000Author Commented:
I tried that, no change.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Dave BaldwinFixer of ProblemsCommented:
This works fine.  Displays 'hallo PHP wereld!' twice.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>	... </title>
	</head>
	<body>
		<p>
			<?php
			echo("hallo PHP wereld!"); 
			print("hallo PHP wereld!"); 
			?>
		</p>
	</body>
</html>

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
By the way, this has to be saved as 'myfile.php' with the php extension for it to be processed thru the PHP interpreter.  It won't work as 'myfile.html'.
0
 
ruud00000Author Commented:
Hello Dave,

The code you provided works fine, since the
<?xml version="1.0"encoding="UTF-8"?>  
line is not included.
However when this is included (see question) the problem arises, also (NOT to be expected) when short_open_tag is set to 'Off' in php.ini.

If I understand your answer well you say I shouldn't want to use xml commands in a XHTML document when using PHP, but the whole idea of using the <?php instead of the short tag <? is that is should work well also in combination with xml commands? Correct me if I'm wrong.
0
 
Dave BaldwinFixer of ProblemsCommented:
XHTML is not XML, it is only kind of related.  XHTML uses HTML tags in a particular way.  It requires them to be "well formed" with both open and close tags.  See this page for more detail: http://en.wikipedia.org/wiki/XHTML.  If you are designing web pages, see this page for the acceptable DOCTYPES: http://www.w3.org/QA/2002/04/valid-dtd-list.html

The long tag versus short tag (<?php versus <?) is a setting in the php.ini on your server.  If you  put the code below on your server as a file called phpinfo.php and access it thru your web browser, it will tell you all of the PHP settings and modules in use on your server.
<?php
phpinfo();
?>

Open in new window

0
 
ruud00000Author Commented:
don't feel my question was answered
0
 
Dave BaldwinFixer of ProblemsCommented:
I'm sorry you don't feel your question was answered.  There are a lot of details about both XML and XHTML and PHP on http://www.w3schools.com/ .  I refer to them a lot because they list almost ever command and format available for a lot of web technologies.  

XML and XHTML are not interchangeable and you can't use the headers or DOCTYPEs interchangeably either.  Yes, you should use long tags <?php with XML because the XML header tag <?xml  contains a short tag and your php could confuse the two if you didn't.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now