Jeaf Gilbert
Jeaf Gilbert

Reputation: 11981

Different file_get_contents() result on different hostings

Code:

<?php
    $string = file_get_contents($url); 
    var_dump($string);
?>

There are different results from file_get_contents() for two different hosts.

Is there any server configuration that I have to change?

Upvotes: 2

Views: 233

Answers (2)

nc.
nc.

Reputation: 7249

Try this:

$context = stream_context_create(array(
'http' => array(
    'method' => 'GET',
    'header' => implode("\r\n", array(
            'Accept-Charset: ISO-8859-1',
    'Accept-Encoding: ',
    )),
)));

$string= file_get_contents($url, null, $context);    
var_dump($string);

Upvotes: 3

Dan Grossman
Dan Grossman

Reputation: 52372

It looks gzipped. I suggest using a more intelligent utility than file_get_contents, like cURL.

Upvotes: 1

Related Questions