ExamVeda
Login
Home
11
Which of the following functions retrieve the entire contents of a file in such a way that it can be used as part of an expression?
1. file_get_contents()
2. fgets()
3. fopen()
4. file()
5. readfile()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
12
fgets() is used to read a file one line at a time.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
13
What is the difference between stat() and fstat()?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
14
flock() is used to unlock a file so that two or more people do not get access to it at the same time.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
15
Which of the following functions reads the entire contents of a file?
1. fgets()
2. file_get_contents()
3. fread()
4. readfile()
5. file()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
What is the purpose of basename() function?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
17
What should you do if your script is having problem recognizing file endings from a text file saved on a platform different from the one you’re reading it on?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
The ............ function checks if the "end-of-file" (EOF) has been reached.
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
19
The ........... function is used to read a single character from a file.
Discuss
Answer & Solution
Answer: Option A
Solution:
Option A: fgetc()
This function in PHP is used to read a single character from a file. It retrieves the next character from the file pointer and advances the file pointer position to the next character.

Option B: fgets()
The fgets() function is used to read a line from a file. It retrieves a line of text from the file pointer, including the newline character at the end of the line.

Option C: fget()
There is no fget() function in PHP related to file reading. This option is incorrect.

Option D: fgetf()
There is no fgetf() function in PHP related to file reading. This option is incorrect.

Conclusion:
The function used to read a single character from a file in PHP is fgetc() (Option A). This function is specifically designed to fetch individual characters from the file, making it the correct answer to the question.