I want to check if the content of a text file is the same as another, and if it isn't, write one into the other. My code is as follows:
<?php $file = "http://example.com/Song.txt";
$f = fopen($file, "r+");
$line = fgets($f, 1000);
$file1 = "http://example.com/Song1.txt";
$f1 = fopen($file1, "r+");
$line1 = fgets($f1, 1000);
if (!($line == $line1)) {
fwrite($f1,$line);
$line1 = $line;
};
print htmlentities($line1);
?>
The line is being printed out, but the content isn't being written in the file.
Any suggestions about what might be the problem?
BTW: Im using 000webhost. I'm thinking it's the web hosting service but I've checked and there shouldn't be a problem. I've also checked the fwrite
function here: http://php.net/manual/es/function.fwrite.php.
Please, any help will be very aprecciated.