Page 200 - Open Soource Technologies 304.indd
P. 200
Unit 11: Directories and Files
File Validator: The file validator helps validating files and even image file types. Notes
Fopen: Opens file or URL, fopen() binds a named resource, specified by filename, to a stream.
Home Directory: The part of the hard disk where you are authorized to save data is called
home directory.
$lines: contents of YourFile.txt into the array called $lines.
/tmp: There is a general directory called/tmp where every user can write files.
1. Write all PHP Code. For File Write: Overwriting.
2. Write all PHP Code. For File Write: Fwrite Function.
11.10 Self Assessment Questions
1. File () is similar to fgets in that it reads the data one line at a time, however it returns it
all at once into an array.
(a) True (b) False
2. The file validator helps validating files and even image file types.
(a) True (b) False
3. Manipulating files is a basic necessity for
(a) serious programmers (b) normal programmers
(c) programmers (d) none of the above.
4. $our FileName = “testFile.txt”;
(a) True (b) False
5. We will be using function to read the content by using a file pointer.
(a) Thread() (b) Fread()
(c) Fread_() (d) All of the above.
6. Write a way to look at the content of a file
(a) with an editor (b) within editor
(c) without an editor (d) all of the above.
11.11 Review Questions
1. What do you mean by truncating a file?
2. What are the three basic ways to open a file and the corresponding character that PHP
uses?
3. How to write data to a Text File?
4. What is the procedure to include files?
5. What precautions should be taken while manipulating files?
LOVELY PROFESSIONAL UNIVERSITY 195