Ok, let me tell you that I am newbie , but there is something that I don't quite understand. I do know how to open file, read from it. That's easy. BUT, when I add something, and then want to present file, before reading, and after reading , I have problem. Here is why. I tried doing this code:
<html>
<head>
</head>
<body>
<?php
if(file_exists("test.txt")) {
$fajl = fopen("test.txt","r");
echo "Fajl pre izmene: <br>";
while(!feof($fajl)) {
$read = fgets($fajl);
echo $read . "<br>";
}
fclose($fajl);
$fajl = fopen("test.txt","a+");
$add = "AOE = Area of effect";
fwrite($fajl,$add);
echo "Fajl nakon izmene:<br>";
while(!feof($fajl)) {
$read = fgets($fajl);
echo $read . "<br>";
}
fclose($fajl);
} else {
echo "Vas fajl ne postoji";
}
?>
</body>
</html>
test.txt file have:
BRB = Be right back
OMG = Oh my god
Now, I thought that , if I read file first, then close it, and then again open it for adding more into it, and after reading it, close it. It seems that first part of code works, but second one, do not. What can be the problem, all this seems bizzare to me.