CopyPastor

Detecting plagiarism made easy.

Score: 0.881044371260537; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2017-02-17
by amit 1984

Original Post

Original - Posted on 2011-06-23
by KingCrunch



            
Present in both answers; Present only in the new answer; Present only in the old answer;

It's ok, but the way you are doing it is wrong (at least "not correct at all").
`fgets()` returns false, if the end of the file is reached, thus you should test against false instead. It works for you, because you use the "simple" equality operator (==), that will case null to false, when comparing against a boolean. Returns a string of up to length - 1 bytes read from the file pointed to by handle. If there is no more data to read in the file pointer, then FALSE is returned. If an error occurs, FALSE is returned. This means, it have to look like: while (($c = fgets($f)) !== false) { doSomethingWith($c); }
It's ok, but the way you are doing it it's wrong (at least "not correct at all"). [`fgets()`][1] returns `false`, if the end of the file is reached, thus you should test against `false` instead. It works for you, because you use the "simple" equality operator (`==`), that will case `null` to `false`, when comparing against a boolean. > Returns a string of up to length - 1 bytes read from the file pointed to by handle. If there is no more data to read in the file pointer, then FALSE is returned. > > If an error occurs, FALSE is returned. This means, it have to look like while (($c = fgets($f)) !== false) { doSomethingWith($c); } [1]: http://php.net/fgets

        
Present in both answers; Present only in the new answer; Present only in the old answer;