Create temporary files
Several benefits of creating temporary files:
1. Delete them after use
2. There is no need to maintain the deletion status of this file
For example: I It is necessary to transfer the file contents of A to B and the file contents of B to C.
Just like in real life, I can first use a temporary bottle to fill B's water, and then write A's data into B. Add the water from the temporary bottle to C.
Let’s learn this function:
resource tmpfile ( )
Function: Create a temporary file and return resources type. The file is deleted when it is closed.
<?php //創(chuàng)建了一個臨時文件 $handle = tmpfile(); //向里面寫入了數(shù)據(jù) $numbytes = fwrite($handle, '寫入臨時文件'); //關(guān)閉臨時文件,文件即被刪除 fclose($handle); echo '向臨時文件中寫入了'.$numbytes . '個字節(jié)'; ?>