About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > File Open and Close...

   Browse by title articles:
   What is hot:

Date

File Permissions

File Open and Close

Creating Directories

Email - Basics

Email - Multiple Recipients

Strings - Pulling apart
Be the Master of Your Printer
Meta Tags- What Are They and Which Search Engines Use Them?
BaseScript
Prev articles12345678910 11 12Next articles



File Open and Close


Computer & I'net articlesFile Open and Close

by David Stanley    



The fopen command is used to open a specific file.
$myfile = fopen ("filename.ext","mode");

Before opening a file however, you have to decide on what will be happening to the file :

1. Do you want to open the file just to read the contents?
2. Do you want to be able to write information to the file?
3. Do you want to delete the current contents of the file and replace them with new data?
4. Do you want to write to the start or end of the file?

Once you've decided on the outcome, the correct MODE is used in opening the file. The MODE part will set the open file for :

r Read only. Pointer set at top of file data.
r+ Read and write. Pointer set at top of file data.
w Write only. Any existing data will be deleted. If file is not found, PHP will create one.
w+ Read and write. Any existing data will be deleted. If file is not found, PHP will create one.
a Appending only. New data will be written at the end of the existing file data.
a+ Read and appending. New data will be written at the end of the existing file data.

When you are done with the data transfer to or from the file, it must be closed.
fclose ($myfile);



-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Car Cost Compare




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com