Consider a scenario where you're building a CMS and you want to log errors to a specific file. Which PHP functions would be most suitable to open and write to this file?
- fopen() and fwrite()
- readfile() and copy()
- file_get_contents() and file_put_contents()
- file() and fwrite()
To open and write to a specific file in PHP, you should use fopen() to open the file and fwrite() to write to it. These functions offer fine-grained control over file handling, crucial for logging errors.
Loading...
Related Quiz
- The keys in a PHP associative array are always numeric.
- What are the differences between a trait and a class in PHP?
- What function do you use in PHP to load an XML document into a DOM object?
- The json_encode() function is used to encode a PHP array into a JSON object.
- You are writing a PHP script and you need to collect form data, but you don't know if the data was sent using the GET or the POST method. How would you do this using the $_REQUEST superglobal?