1. How do you open a file in PHP?
Answer:
Explanation:
The fopen() function is used to open a file in a specified mode in PHP.
2. Which mode in fopen() function is used to read from a file in PHP?
Answer:
Explanation:
The 'r' mode in the fopen() function is used for reading from a file.
3. How do you write to a file in PHP?
Answer:
Explanation:
Both fwrite() and fputs() functions are used to write to a file in PHP.
4. What does the file_get_contents() function do in PHP?
Answer:
Explanation:
The file_get_contents() function reads the entire file into a string.
5. How do you close an opened file in PHP?
Answer:
Explanation:
The fclose() function is used to close an opened file in PHP.
6. What is the purpose of the file_put_contents() function in PHP?
Answer:
Explanation:
The file_put_contents() function writes a string to a file, creating the file if it does not exist.
7. Which function checks if a file exists in PHP?
Answer:
Explanation:
The file_exists() function checks whether a file or directory exists.
8. How do you read a single line from a file in PHP?
Answer:
Explanation:
The fgets() function is used to read a single line from a file.
9. Which mode in fopen() is used to write to a file, clearing its contents in PHP?
Answer:
Explanation:
The 'w' mode in fopen() is used for writing to a file, and it clears the file's contents if it already exists.
10. What does the feof() function do in PHP?
Answer:
Explanation:
The feof() function checks if the "end-of-file" (EOF) has been reached.
11. How do you append data to an existing file in PHP?
Answer:
Explanation:
Data can be appended to an existing file using fopen() with 'a' mode or file_put_contents() with the FILE_APPEND flag.
12. Which function deletes a file in PHP?
Answer:
Explanation:
The unlink() function is used to delete a file in PHP.
13. What is the purpose of the file() function in PHP?
Answer:
Explanation:
The file() function reads a file and stores each line as an element in an array.
14. How can you check the file size in PHP?
Answer:
Explanation:
The filesize() function is used to get the size of a file in bytes.
15. What does the move_uploaded_file() function do in PHP?
Answer:
Explanation:
The move_uploaded_file() function is used to move an uploaded file to a new location, commonly used in file uploading processes.
Comments
Post a Comment