//$str0 = "@ \xB1\x31  @";
        $str0 = "\xC0\xA";
        //$str0 = '123';
        $data = ["text" => $str0, "text2" => "123"];
        /*  $fp = fopen('robots.txt', 'r');
        $data = ['file' => $fp];
        $data = ['value' => INF]; */
        $json = json_encode($data);
        $json2 = json_encode($data, JSON_INVALID_UTF8_SUBSTITUTE); // 잘못된 문자 (�)로 대체
        $json3 = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR); // 에러난 곳을  null로 대체
        $json4 = json_encode($data, JSON_INVALID_UTF8_IGNORE); // 잘못된 문자 제거, file pointer나 (NaN, INF,..) 등 있으면 false

 

반응형
Posted by codens