File_Get_Contents不在localhost中显示图片

I've tried using:

header('Content-type: image/jpg');
echo file_get_contents("www.example.com/img.jpg")

and:

function file_get_contents_curl($url) {
$ch = curl_init();

curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       

$data = curl_exec($ch);
curl_close($ch);

return $data;
}
header('Content-type: image/jpg');
echo file_get_contents_curl("www.example.com/img.jpg");

and both methods give me the same broken image with the url pointed to:

http://localhost/01_Tests/filegettest.php

What's the issue? I have the allow_url_fopen = on as well.

edit var dump:

<html>
<body>
<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font       color='#cc0000'>'ÿØÿà&#0;JFIF&#0;&#0;&#0;&#0;&#0;&#0;ÿÛ&#0;„&#0;&#10;&#10;&#10;&#10;&#10;  &#10;   &#13;&#10;&#13;&#10;&#10;&#10;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;&#13;ÿÀ&#0;&#0; &#0;È&#0;ÿÄ&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0; &#10;ÿÄ&#0;H&#0;&#0;&#0;&#0;&#0;&#0;!1&quot;AQ2aq#BR‘   3Sr’“¡±ÁÑÒáðñCTb‚”$%4DcƒÓÿÄ&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0; ÿÄ&#0;=&#0;&#0;&#0;&#0;&#0;&#0;!&quot;1A2QRa‘Bq#Sb’¡ÁÑr‚¢±ðáñ$3ÿÚ&#0;&#0;&#0;?&#0;ò«À„`B0!ŒF#À„`B0!ŒF#À„`B0!ŒF#F#À„`B0!ŒF#À„`B-À„`B0!ŒF#À„`B0!~…ß&quot;¤ÿ&#0;MGÿ&#0;ZàÅç'...</font> <i>(length=13088)</i>