Some time ago, a company often reported timeout on a page, which was originally thought to be caused by sending an email. After the mail is split to asynchronous sending, the timeout problem is not solved. So I carefully studied the code segments near timeout. I found a similar code :? Php?filefopencontacts.csv, r; while! Feof $ fileprint_rfgetc
Some time ago, a company often reported timeout on a page, which was originally thought to be caused by sending an email. After the mail is split to asynchronous sending, the timeout problem is not solved. So I carefully studied the code segments near timeout. I found a similar code :? Php $ file = fopen "contacts.csv", "r"; while! Feof $ file print_rfgetc
Some time ago, a company often reported timeout on a page, which was originally thought to be caused by sending an email. After the mail is split to asynchronous sending, the timeout problem is not solved. So I carefully studied the code segments near timeout.
The following code is found:
In fact, the above Code is the sample code of W3scholl.
If I have not carefully read the PHP manual, I cannot see any problems with this code?
The key to the problem lies in the feof function, which is clearly described in the Manual:
If the passed file pointer is not valid you may get an infinite loop, because feof() fails to return TRUE.
See: http://cn2.php.net/feof
Therefore, if the above Code fails to open the file, it will lead to an endless loop, resulting in page timeout.
Comments | Author: tomheng 85159e08d5f1f50d244825cb03e92c65