1: |
Which functions could you use to add library code to the currently running script?
|
2: |
Which function would you use to find out whether a file is present on your file system?
|
3: |
How would you determine the size of a file?
|
4: |
Which function would you use to open a file for reading or writing?
|
5: |
Which function would you use to read a line of data from a file?
|
6: |
How can you tell when you have reached the end of a file?
|
7: |
Which function would you use to write a line of data to a file?
|
8: |
How would you open a directory for reading?
|
9: |
Which function would you use to read the name of a directory item after you have opened a directory for reading?
|
| |
A1:
| 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(). |
| |
A2:
| You can test for the existence of a file with the file_exists() function. |
| |
A3:
| The filesize() function returns a file's size in bytes. |
| |
A4:
| The fopen() function opens a file. It accepts the path to a file and a character representing the mode. It returns a file resource. |
| |
A5:
| 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. |
| |
A6:
| The feof() function returns true when the file resource it is passed has reached the end of the file. |
| |
A7:
| You can write data to a file with the fputs() function. |
| |
A8:
| The opendir() function enables you to open a directory for reading. |
| |
A9:
| The readdir() function returns the name of a directory item from an opened directory. |