3v4l.org

run code in 300+ PHP versions simultaneously
<?php @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS! @ini_set('display_errors', '1'); global $argv; #TODO: check for number of arguments passed $zip_info = pathinfo($argv[1]); if ($zip_info["extension"] !== "zip") { echo "Incorrect file provided. Please provide .zip file.\n"; exit(); } #TODO: check if user provided valid directory $copy_to_folders = get_folders($argv[2]); var_dump($argv); $zip_file = $argv[1]; echo $zip_file; $zip_parts = explode('.', $zip_file); $zip_name = $zip_parts[0]; $path_to_zip = pathinfo(realpath($zip_file), PATHINFO_DIRNAME); $zip = new ZipArchive; var_dump($zip); $result = $zip->open($zip_file); var_dump($result); if ($result === true) { $zip->extractTo($path_to_zip); $zip->close(); echo "success \n"; } function get_folders($path) { if(!is_dir($path)){ echo "ERROR: $path isn't a directory. Please provide valid directory for path.\n"; exit(); } $browsers = array(); if ($handle = opendir($path)) { chdir($path); $current_dir = getcwd(); while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $browser = $current_dir . "/" . $entry; $browsers[] = $browser; } } closedir($handle); } return $browsers; }
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined array key 1 in /in/9hfVP on line 9 Deprecated: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /in/9hfVP on line 9 Warning: Undefined array key "extension" in /in/9hfVP on line 10 Incorrect file provided. Please provide .zip file.
Output for 8.0.0 - 8.0.30
Warning: Undefined array key 1 in /in/9hfVP on line 9 Warning: Undefined array key "extension" in /in/9hfVP on line 10 Incorrect file provided. Please provide .zip file.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Notice: Undefined offset: 1 in /in/9hfVP on line 9 Notice: Undefined index: extension in /in/9hfVP on line 10 Incorrect file provided. Please provide .zip file.
Output for 5.2.3 - 5.2.17
Notice: Undefined offset: 1 in /in/9hfVP on line 9 Notice: Undefined index: extension in /in/9hfVP on line 10 Incorrect file provided. Please provide .zip file.
Output for 4.3.6 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Notice</b>: Undefined offset: 1 in <b>/in/9hfVP</b> on line <b>9</b><br /> <br /> <b>Notice</b>: Undefined index: extension in <b>/in/9hfVP</b> on line <b>10</b><br /> Incorrect file provided. Please provide .zip file.
Output for 4.3.0 - 4.3.5
Incorrect file provided. Please provide .zip file.

preferences:
316.43 ms | 401 KiB | 464 Q