I have a text file called things.txt with:
thing1
thing2
thing34
and php:
$fp = fopen('things.txt');
while (!feof($fp)) {
$line = fgets($fp);
echo $line."<br>";
}
fclose($fp);
and it’s not working…any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
fopen()requires at least two parameters!The second one is the mode.
r(“readonly, pointer at the beginning, no truncate”) should work fine here, because you only read it. For the other modes, refer the manual (linked above).You should change your development settings to
because you should get an error for this. However, the reason for the infinite loop is, that
fopen()returnsnullandfeof(null)returnsfalseandwhile(!false)is an infinite loop.