3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.3.0 - 7.1.0
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.2 - 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.0 - 4.3.1
Notice: Undefined index: extension in /in/9hfVP on line 10 Incorrect file provided. Please provide .zip file.