
CONTENTS
vii
Breaking Out of a Control Structure or Script ....................................47
Next: Saving the Customer’s Order ......................................................47
2 Storing and Retrieving Data 49
Saving Data for Later ..........................................................................50
Storing and Retrieving Bob’s Orders ..................................................50
Overview of File Processing ................................................................52
Opening a File ......................................................................................52
File Modes ......................................................................................52
Using fopen() to Open a File ..........................................................53
Opening Files for FTP or HTTP ....................................................54
Problems Opening Files ..................................................................55
Writing to a File ....................................................................................57
Parameters for fwrite() ....................................................................57
File Formats ....................................................................................58
Closing a File ........................................................................................58
Reading from a File ..............................................................................59
Opening a File for Reading: fopen() ..............................................60
Knowing When to Stop: feof() ........................................................60
Reading a Line at a Time: fgets(), fgetss(), and fgetcsv() ..............60
Reading the Whole File: readfile(), fpassthru(), file() ....................61
Reading a Character: fgetc() ..........................................................62
Reading an Arbitrary Length: fread() ..............................................63
Other Useful File Functions ................................................................63
Checking Whether a File Is There: file_exists() ............................63
Knowing How Big a File Is: filesize() ............................................63
Deleting a File: unlink() ..................................................................63
Navigating Inside a File: rewind(), fseek(), and ftell() ..................64
File Locking ..........................................................................................65
Doing It a Better Way: Database Management Systems ......................66
Problems with Using Flat Files ......................................................66
How RDBMSs Solve These Problems ............................................67
Further Reading ....................................................................................67
Next ......................................................................................................67
3 Using Arrays 69
What Is an Array? ................................................................................70
Numerically Indexed Arrays ................................................................71
Initializing Numerically Indexed Arrays ........................................71
Accessing Array Contents ..............................................................72
Using Loops to Access the Array ....................................................73
00 7842 FM 3/6/01 3:38 PM Page vii
Comentarios a estos manuales