Ive been reading this book and I got to the chapter about writing and reading text files, i understood the writing script, but this one confused me:
<html>
<head>
<title>Bob's Auto Parts - Customer Orders</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Customer Orders</h2>
<?
$fp = fopen("../../orders/orders.txt", "r");
flock($fp, 1);
if (!$fp)
{
echo "<p><strong>No orders pending."
."Please try again later.</strong></p></body></html>";
exit;
}
while (!feof($fp))
{
$order= fgets($fp, 100);
echo $order."<br>";
}
flock($fp, 3);
/*
echo "Final position of the file pointer is ".(ftell($fp));
echo "<br>";
rewind($fp);
echo "After rewind, the position is ".(ftell($fp));
echo "<br>";
*/
fclose($fp);
?>
</body>
</html>
What does the while(!feof($fp)) do?
Why do you need it? I thought while loops needed conditions in them right? Is flock($fp, 30); a php function? What does it do?
Also, what does the ! infront of FEOF mean? I see that in front of the error reporting too.
Sorry for asking so many questions, but Imj really excited in learning PHP, I just got the book tonight lol.