balkondemiri
balkondemiri

Reputation: 953

PHP string charset is not stable

I get data with this code

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);
     $content = file_get_contents('http://tr.betboo672.com/services/InPlayApp.mvc/GetInPlaySports?isShrinked=false', false, 
    $context);
    echo $content;

Sometimes be problem charset encoding. It is not stable (change character encoding each refresh page). Sometimes get this data

���`I�%&/m�{J�J��t��`$ؐ@�������iG#)�*��eVe]f@�흼��{����{����;�N'���?\fdl��J�ɞ!���?

mb_detect_encoding function always return UTF-8 I tried this Detect encoding and make everything UTF-8

Upvotes: 0

Views: 69

Answers (1)

the_nuts
the_nuts

Reputation: 6064

Is your page encoding set to utf8?

header('Content-Type: text/html; charset=utf-8');

Upvotes: 1

Related Questions