Similar points: The file_put_contents() function writes a string to a file, which has the same function as calling fopen(), fwrite() and fclose() in sequence.
Difference: Using FILE_APPEND in the file_put_contents() function can avoid deleting the existing content in the file, that is, realizing the append function when writing the same file multiple times.
For example:
echo file_put_contents("test.txt","Hello World. Testing!",FILE_APPEND);
file_put_contents writes the string into test.txt in the form of append,
fwrtie will clear the previous record and only retain the currently written content
$file = fopen("test.txt","w"); echo fwrite($file,"Hello World. Testing!"); fclose($file);