13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

xii<br />

Contents<br />

Writing to a File 67<br />

Parameters for fwrite() 68<br />

File Formats 68<br />

Closing a File 69<br />

Reading from a File 71<br />

Opening a File for Reading: fopen() 72<br />

Knowing When to Stop: feof() 73<br />

Reading a Line at a Time: fgets(), fgetss(), <strong>and</strong><br />

fgetcsv() 73<br />

Reading the Whole File: readfile(), fpassthru(), <strong>and</strong><br />

file() 74<br />

Reading a Character: fgetc() 75<br />

Reading an Arbitrary Length: fread() 75<br />

Using Other Useful File Functions 76<br />

Checking Whether a File Is There:<br />

file_exists() 76<br />

Determining How Big a File Is: filesize() 76<br />

Deleting a File: unlink() 76<br />

Navigating Inside a File: rewind(), fseek(), <strong>and</strong><br />

ftell() 76<br />

Locking Files 78<br />

A Better Way: Database Management Systems 79<br />

Problems with Using Flat Files 79<br />

How RDBMSs Solve These Problems 80<br />

Further Reading 80<br />

Next 80<br />

3 Using Arrays 81<br />

What Is an Array? 81<br />

Numerically Indexed Arrays 82<br />

Initializing Numerically Indexed Arrays 82<br />

Accessing Array Contents 83<br />

Using Loops to Access the Array 84<br />

Arrays with Different Indices 85<br />

Initializing an Array 85<br />

Accessing the Array Elements 85<br />

Using Loops 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!