What are the differences between using fprintf in PHP 4.x and PHP 5?

In PHP 4.x, the fprintf function is used to write a formatted string to a file. However, in PHP 5, the preferred method for writing to a file is using the fwrite function. To update code from PHP 4.x to PHP 5, you should replace fprintf with fwrite for writing to files.

// PHP 4.x
$file = fopen("example.txt", "w");
fprintf($file, "Hello, World!");
fclose($file);

// PHP 5
$file = fopen("example.txt", "w");
fwrite($file, "Hello, World!");
fclose($file);