Question: I have went through many solutions [1](https://stackoverflow.com/questions/15488538/json-php-array-to-javascript) but not getting json in java script getting an error.In my myfile.php file it contains

```
<?php
 ................
print json_encode($data, JSON_NUMERIC_CHECK);
mysql_close($con);
?>
<html>
    <head>
         <script type="text/javascript" src="jquery.min.js"></script>
         <script type="text/javascript" src="example2.js"></script>
        <script>
           var json= loadJsonFromPHP(<?php echo json_encode($data) ?>);
           //var json= <?php echo json_encode($data) ?>;
        </script>
    </head>
    <body></body>
</html>

```

In my example2.js file

```
var loadJsonFromPHP = function(json) {
    console.log(json);
}

function init(){
  // init data
  var json =loadJsonFromPHP(json);
 }

```

getiing an error **Cannot read property 'id' of undefined** at **console.log(json);**,I am new to PHP ,and have no idea where am i getting wrong,

i have tried with .getJson in my js but getting error ReferenceError: $ is not defined 

```
function init(){
      // init data
var json=$.getJSON('http://localhost/myfile.php', function(data) {
    console.log(data);
});

}

```

Stuck completely,any help,thanks.

Answer: 
Any good `diff` program will show you differing blocks. You can then load the result into a graphical comparison program, scan the results visually, ignore the blocks that you *know* are different, then scream when you hit the block you didn't expect.

For example, *WinMerge*:

[![](https://i.stack.imgur.com/srIYv.gif)](https://i.stack.imgur.com/srIYv.gif)  

(source: [majorgeeks.com](http://www.majorgeeks.com/index.php?ct=files&action=file&id=1668))
> 
> (and yes, relative seeks aren't expected to work on files opened in text mode) 
>  -[Cubbi](http://www.cplusplus.com/forum/windows/96080/#msg515913)
> 
> 
> 

So there's the answer - opening in std::ios::binary mode fixes the problem fine.