I created a class which should creates new binary file (called 4.ip) in the case that the file does not exist. Method reset() does the job. Then I try to add some numbers from Ip to the file. I try to use binary mode but It looks like it corrupts the file. First value 0E is written correctly. I have marked the BOM which was created in the reset method (idk if is this right when it should be binary file.


before error


To see the above, uncomment the die(); on line 413. Then to see the bellow, comment it back.


When I try to write the second value (line 415), the file looks corrupted, and all the 0000 disappear.


error on second fwrite


This is the source code

please see the lines 412-418.

PHP Code:
<?php
include("scan_ips_class.php");
$scanIPs = new Scan_ips;
?>
Please help because I really cannot find out solution, and I am lost. Trying to solve this few days.