Which of the following are ways to create a file in PHP?

  • fopen() with 'w' mode
  • file_put_contents()
  • touch()
  • mkdir()
In PHP, you can create a file by using the fopen() function with the appropriate file path and 'w' mode, which will create the file if it doesn't exist. Additionally, you can use the file_put_contents() function to create a file and write contents to it. The touch() function is used to change file timestamps, and the mkdir() function is used to create directories, not files.
Add your answer
Loading...

Leave a comment

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