I'm using the following function to get a webpage from a webserver. However, the resulting page contains characters which are not not supposed to be in the page and which are not in there when I visit the same page with IE...
What's wrong with the function?
function get_page($host, $page) {
global $cookie;
//echo "Getting $page<br>";
$fp = fsockopen($host, "80", $errno, $errstr, 30);
if (!$fp) {
echo "ERRORRRR!!!<br><br>";
echo "$errstr ($errno)<br />\n";
}
else {
$out = "GET $page HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie; style=null\r\n";
$out .= "\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$str .= fgets($fp, 20);
}
echo "received a string of " . strlen($str) . " characters";
echo "<br><br>";
fclose($fp);
return $str;
}
}
part from the resulting webpage ...
border="0" ce
48b
llspacing="0">
Mind the 48b which should of course not be there ...
In the meantime I have discoverd that it only happens with this particular host and that the same weird stuff can be found when sniffing my own ehternet-card and browsing with IE ... however, IE takes those codes out...