PHP File Handling
PHP File Handling - Important Points
1. | What is the function used to open a file in PHP? |
---|
A. fopen()
B. readfile()
C. fwrite()
D. fclose()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
fopen() is the function used to open a file in PHP. It returns a file pointer, which is used in other functions like fwrite(), fgets(), etc.
2. | What is the mode used for opening a file in PHP for reading only? |
---|
A. r
B. w
C. a
D. x
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The mode used for opening a file in PHP for reading only is "r".
3. | What is the mode used for opening a file in PHP for writing only? |
---|
A. w
B. r
C. a
D. x
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The mode used for opening a file in PHP for writing only is "w".
4. | Which function is used to write data to a file in PHP? |
---|
A. fwrite()
B. fread()
C. fopen()
D. fclose()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
fwrite() is the function used to write data to a file in PHP.
5. | What is the function used to read data from a file in PHP? |
---|
A. fgets()
B. fwrite()
C. fopen()
D. fclose()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
fgets() is the function used to read data from a file in PHP.