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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *