Saturday, August 10, 2013

File I/O

$file = fopen("customers.txt", "r");
   

  • Privileges at the beginning of the file

   r - is for read privilege
   r+ - for read write
   w - just write 
   w+ - will delete content and give you read and write
   a - will give you write privileges


  • Privileges at the end of the file
   a - read
   a+ - read and write as you may have guessed

And that's it! At least until I know why on earth I would want to do this, but supposedly this is very useful.


How to grab stuff off of the web

Okay: I actually checked this and it throws an error but it does create the text file like it's supposed to:)

<?php
$file2 = fopen("http://stormbloom.com", "rt");//rt - read in text
while (!feof($file2))//This condition equals "NOT" to the end of the file so it will continue to execute until the end is reached
{
$stormbloom .= fgetss($file2, 1024);//fgetss strips out tags, 1024 - you want the first 1024 chatracters (just always type this)
}
fclose($file2);//close the file
$file3 = fopen("stormbloom.txt", "wt");//Write the info to text file; give the ability to write text
fwrite($file3, $stormbloom);
fclose($file3);
?>

This is pretty damn cool

_________________________________

____________________________________________

No comments:

Post a Comment