$file = 'myFile.txt'; if (file_exists($file)) { $content = file_get_contents($file); echo $content; } else { echo 'File not found'; }
$file = 'myFile.txt'; $content = 'Hello World!'; $fileHandle = fopen($file, 'w'); fwrite($fileHandle, $content); fclose($fileHandle);
$file = 'myFile.txt'; if (file_exists($file)) { unlink($file); echo 'File deleted successfully'; } else { echo 'File not found'; }This code checks if the file exists and if it does, it deletes the file. The function used is `unlink()` to delete the file. PHP Filesystem is a built-in PHP library that is included in the PHP core. No external package or library is required for using it.