WHAT A LAMP Rotating Header Image

File operation in PHP

Open File

() returns false when the file can not be openned.

if ($fp=fopen(“test.txt”, “w”)){

//do something

}

Close File

($fp);

Reading from file

fgets($fp, 1024);  // get 1024 bytes

($fp);  // end of the file

($fp, 16);  // get 16 bytes

($fp, 64);  // move point to particular byte

($fp);  // get the first letter

($fp, “Hello World”);  //write into file

fputs($fp, “Hell world again”); // add into file

Looking Files

($fp, LOCK_SH); //share

flock($fp, LOCK_EX); //exclusive

flock($fp, LOCK_UN); //unlock

0 Comments on “File operation in PHP”

Leave a Comment