I’m having this problem with validating a document that contains some basic PHP variables. Mainly I’m using html’s h1, h2, and pre codes for formatting the text.
My problem is that when I validate the document, it comes out with an error.
The problem area is this part of the file:
<h2>Server Info</h2>
<pre>
<?php
echo $_SERVER;
print_r(var_dump($_SERVER));
?>
</pre>
I’m trying to figure out what’s going whenever I try to validate it, I get an undefined element error.
Here’s a link to the validation page: http://goo.gl/napu
EDIT: Link to the complete HTML source that’s getting the error: http://pastebin.com/Kc6wh5s6
2ND EDIT: Used Pekka‘s suggestion and inserted the PHP snippet and now the page has been passed. Thanks!
The problem is that the
$_SERVERdump contains code that looks like a XML element, namely<ADDRESS>. The validator is obliged to deal with that like with every other HTML element, and fails.The solution would be to run a
htmlentities()over the output to mask any included HTML or XML, e.g. like so: