Is there any way to remove the contents of an file in php, do we have any php command that does that, I know unlink but I do not want to delete the file instead
unlink
ftruncate — Truncates a file to a given length
Example
$handle = fopen('/path/to/file', 'r+'); ftruncate($handle, 0); fclose($handle);
But you have to open the file.