I has passed a small test to check which function is faster to create a new file.
file_put_contents vs touch
Copy code The code is as follows:
for($i = ; $i < ; 100; $i++)
{
file_put_contents('dir/file'.$i, '');
}
?>
Copy code The code is as follows:
for($i = ; $i < 100; $i++)
{
touch('dir/file'.$i);
}
?>
The above introduces the code to create an empty file in PHP [file_put_contents vs touch], including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.