Could someone tell me whats wrong with this code? It doesnt seem to be working and isnt poping up any error either

PHP Code:
<?
    function getLinks($url) {
        if(!$url) {
            return "Error opening $url";
            }
        else {
            $url = eregi_replace("http://", "", $url);
            $fp = fsockopen("$url", 80, &$errorstr, &$errorno, 30) or DIE("could not connect $errorstr
($errorno)");
            fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
                if($fp) {
                    while(!feof($fp)) {
                        $data .= fgets($fp, 4096);
                                        }
                    fclose($fp);
                        }
                else {
                    return "Error opening $url";
                    }
            }
preg_match_all ("/<a[^>]*>(.+)<\/a>/imU", $data, $matches);
        $matches = $data;
        return $matches;
        }

    $links = getLinks("www.yahoo.com");
    for ($i=0;$i<count($links);$i++) {
                echo "$links[$i]<br>";
                                        }

?>