In PHP, the ______ function is used to read the contents of a file.
- readfile()
- file_get_contents()
- fread()
- include()
In PHP, the fread() function is used to read the contents of a file. It takes the file handle obtained from fopen() as the first parameter and the maximum number of bytes to read as the second parameter. This function returns the content of the file as a string. Alternatively, you can use file_get_contents() to read the entire file into a string or other file reading functions depending on your specific use case.
Loading...
Related Quiz
- What is the main purpose of a constructor in a PHP class?
- Which PHP loop is suitable when you want to iterate over a block of code for a known number of times?
- In PHP, variables declared inside a function can be accessed outside of that function.
- How do you use Regular Expressions in PHP?
- Can you provide an example of a superglobal in PHP?