Sprouts
Regular Member
- Mar 20, 2010
- 464
- 328
I'm trying to code a small project and I'm pretty noob at php. I've coded the following with the help of google but it doesn't seem to work?
When I run the PHP file off my server there are no errors and this is what is shown:
1.txt contains the text "quickla"
2.txt contains the text "quickly"
How can the files be equal?
The data is echoed correctly so it's not that, the files are definitely different so it's not that, the else statement works as I tested it with "1 < 2" and "2 < 1" and it told me the correct results?
I'm really confused.
EDIT: Both files have 777 permissions too and the problem still occurs?!
PHP:
<?php
$file1 = "1.txt";
$openfile1 = fopen($file1, 'r');
$data1 = fread($openfile1, 150);
fclose($openfile1);
echo $data1;
?>
<br>
<?php
$file2 = "2.txt";
$openfile2 = fopen($file2, 'r');
$data2 = fread($openfile2, 150);
fclose($openfile2);
echo $data2;
?>
<br>
<?php
if ($data1 = $data2) {
echo "the files are equal";
} else {
echo "the files are not equal";
}
?>
When I run the PHP file off my server there are no errors and this is what is shown:
quikla
quikly
the files are equal
1.txt contains the text "quickla"
2.txt contains the text "quickly"
How can the files be equal?
The data is echoed correctly so it's not that, the files are definitely different so it's not that, the else statement works as I tested it with "1 < 2" and "2 < 1" and it told me the correct results?
I'm really confused.
EDIT: Both files have 777 permissions too and the problem still occurs?!
Last edited: