________ is used to write a string to a file.
-
file_put_string
-
file_put_contents
-
file_put_char
-
none of these
B
Correct answer
Explanation
file_put_contents() is the correct PHP function for writing a string to a file. It can write data to a file in a single call, optionally with flags like FILE_APPEND (to add to existing content) or LOCK_EX (to get an exclusive lock). This is simpler than the traditional fopen/fwrite/fclose sequence.