@diafol — How come you put in those closing PHP tags? Just curious. It's PHP only. ;D
prior versions of php have insisted on closures, EOF does not close the php script.
currently the manual says
If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.
not always good advice, , just because it is on the php site 'twas still written by people
if you have whitespace after the closing '?>' strange things happen
solution: don't screw up.
stranger things happen
If you include('file without ?>');
<doctype>
<html>
<head>
bla bla bla
</head><body>
bla bla bla
<?php include('file without ?>'); ?>
bla bla bla
</body></html>
expands to
<doctype>
<html>
<head>
bla bla bla
</head><body>
bla bla bla
<?php $file = "xpath.html";
$doc = new DOMDocument();
$doc->loadHTMLFile($file);
$xpath = new DOMXpath($doc);
$elements = $xpath->query("*/div[@class='prod_text']/a");
$p = "Couldn't find the category name";
if (!is_null($elements)) {
$p = $elements->item(0)->childNodes->item(0)->nodeValue;
}
echo $p;
bla bla bla
</body></html>
and fails dismally
solution: close script files & dont screw up
pure php, makes little or no difference;
close the script without extra whitespace