The workshop is designed to help you anticipate possible questions, review what you've learned, and begin putting your knowledge into practice.
What functions do you use to add library code to the currently running script?
You can use the require() or include() statement to incorporate PHP files into the current document. You could also use include_once() or require_once().
What function do you use to find out whether a file is present on your file system?
You can test for the existence of a file with the file_exists() function.
How do you determine the size of a file?
The filesize() function returns a file's size in bytes.
What function do you use to open a file for reading or writing?
The fopen() function opens a file. It accepts the path to a file and a character representing the mode. It returns a file resource.
What function do you use to read a line of data from a file?
The fgets() function reads data up to the buffer size you pass it, the end of the line, or the end of the document, whichever comes first.
How can you tell when you've reached the end of a file?
The feof() function returns true when the file resource it's passed reaches the end of the file.
What function do you use to write a line of data to a file?
You can write data to a file with the fputs() function.
How do you open a directory for reading?
The opendir() function enables you to open a directory for reading.
What function do you use to read the name of a directory item after you've opened a directory for reading?
The readdir() function returns the name of a directory item from an opened directory.
Create a form that accepts a user's first and second name. Create a script that saves this data to a file.
Create a script that reads the data file you created in activity 1. In addition to writing its contents to the browser (adding a <BR> tag to each line), print a summary that includes the number of lines in the file and the file's size.