Good time of day. Help to understand the logic.

while (!feof($fg)) { тело цикла } 

If the loop value is true , then the loop body will be executed.
The file descriptor (say at the beginning of the file), which means feof() will return false . ! - denial. It turns out: we deny the negation - we get the truth?
Reaches the end of the file - feof() returns true . We deny the truth, we get a lie? Does the loop stop running?
I am just getting to know PHP. Explain the logic, please.

  • 3
    But you all correctly painted. That's exactly what happens. - VioLet
  • Read Boolean logic and discrete mathematics - neoascetic

2 answers 2

This is exactly what we are doing, until we stumble upon the end of the file.

You can submit it in Russian:

 пока (не конец файла($fg)) { тело цикла } 

Until the end of the file - feof($fg) does not return true - the body of the loop is satisfied, since the condition will be (at the expense of the negation operator) true. As soon as by the beginning of the next iteration it turns out that at the end of the file we get while (!true) = while (false) , and we will not execute the cycle.

    Apparently php for you is the first language. Many do not recommend it. Although I would not say that starting with a high-level language, you can "kill a programmer at the root." Though for me the first language was assembler, the second one was si. I do not think that if I started with php, I would have failed. Learn and enjoy life, in general, and listen to the knowledgeable. I wish you success)