Source Code:
(back to article)
<?php // Open the file for writing and truncate its content $file = fopen('example.txt', 'w'); ftruncate($file, 0); fclose($file); // Check if the file was truncated if (filesize('example.txt') === 0) { echo "File truncated successfully."; } else { echo "Failed to truncate file."; }
Result:
Report an issue