Created
July 26, 2024 14:51
-
-
Save me-suzy/29fcff765b5533999ff9e96027bf31a6 to your computer and use it in GitHub Desktop.
test_zip.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
error_reporting(E_ALL); | |
echo "<h1>Test ZIP functionality</h1>"; | |
if (class_exists('ZipArchive')) { | |
echo "<p>ZipArchive class is available.</p>"; | |
} else { | |
echo "<p>ZipArchive class is NOT available.</p>"; | |
} | |
$test_file = 'test.zip'; | |
$zip = new ZipArchive(); | |
if ($zip->open($test_file, ZipArchive::CREATE) === TRUE) { | |
$zip->addFromString('test.txt', 'Test content'); | |
$zip->close(); | |
echo "<p>Successfully created a test ZIP file.</p>"; | |
} else { | |
echo "<p>Failed to create a test ZIP file.</p>"; | |
} | |
if (file_exists($test_file)) { | |
echo "<p>Test ZIP file exists.</p>"; | |
unlink($test_file); | |
echo "<p>Test ZIP file deleted.</p>"; | |
} else { | |
echo "<p>Test ZIP file does not exist.</p>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment