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; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 70
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
filename:       /in/9hfVP
function name:  (null)
number of ops:  71
compiled vars:  !0 = $argv, !1 = $zip_info, !2 = $copy_to_folders, !3 = $zip_file, !4 = $zip_parts, !5 = $zip_name, !6 = $path_to_zip, !7 = $zip, !8 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BEGIN_SILENCE                                    ~9      
          1        INIT_FCALL                                               'error_reporting'
          2        SEND_VAL                                                 32767
          3        DO_ICALL                                                 
          4        END_SILENCE                                              ~9
    4     5        BEGIN_SILENCE                                    ~11     
          6        INIT_FCALL                                               'ini_set'
          7        SEND_VAL                                                 'display_errors'
          8        SEND_VAL                                                 '1'
          9        DO_ICALL                                                 
         10        END_SILENCE                                              ~11
    6    11        BIND_GLOBAL                                              !0, 'argv'
    9    12        INIT_FCALL                                               'pathinfo'
         13        FETCH_DIM_R                                      ~13     !0, 1
         14        SEND_VAL                                                 ~13
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !1, $14
   10    17        FETCH_DIM_R                                      ~16     !1, 'extension'
         18        IS_NOT_IDENTICAL                                         ~16, 'zip'
         19      > JMPZ                                                     ~17, ->22
   11    20    >   ECHO                                                     'Incorrect+file+provided.+Please+provide+.zip+file.%0A'
   12    21      > EXIT                                                     
   15    22    >   INIT_FCALL_BY_NAME                                       'get_folders'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_DIM_FUNC_ARG                               $18     !0, 2
         25        SEND_FUNC_ARG                                            $18
         26        DO_FCALL                                      0  $19     
         27        ASSIGN                                                   !2, $19
   16    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
   18    31        FETCH_DIM_R                                      ~22     !0, 1
         32        ASSIGN                                                   !3, ~22
   19    33        ECHO                                                     !3
   20    34        INIT_FCALL                                               'explode'
         35        SEND_VAL                                                 '.'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                         $24     
         38        ASSIGN                                                   !4, $24
   21    39        FETCH_DIM_R                                      ~26     !4, 0
         40        ASSIGN                                                   !5, ~26
   22    41        INIT_FCALL                                               'pathinfo'
         42        INIT_FCALL                                               'realpath'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                         $28     
         45        SEND_VAR                                                 $28
         46        SEND_VAL                                                 1
         47        DO_ICALL                                         $29     
         48        ASSIGN                                                   !6, $29
   24    49        NEW                                              $31     'ZipArchive'
         50        DO_FCALL                                      0          
         51        ASSIGN                                                   !7, $31
   25    52        INIT_FCALL                                               'var_dump'
         53        SEND_VAR                                                 !7
         54        DO_ICALL                                                 
   26    55        INIT_METHOD_CALL                                         !7, 'open'
         56        SEND_VAR_EX                                              !3
         57        DO_FCALL                                      0  $35     
         58        ASSIGN                                                   !8, $35
   27    59        INIT_FCALL                                               'var_dump'
         60        SEND_VAR                                                 !8
         61        DO_ICALL                                                 
   28    62        TYPE_CHECK                                    8          !8
         63      > JMPZ                                                     ~38, ->70
   29    64    >   INIT_METHOD_CALL                                         !7, 'extractTo'
         65        SEND_VAR_EX                                              !6
         66        DO_FCALL                                      0          
   30    67        INIT_METHOD_CALL                                         !7, 'close'
         68        DO_FCALL                                      0          
   31    69        ECHO                                                     'success+%0A'
   55    70    > > RETURN                                                   1

Function get_folders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 43
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 24
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 24
Branch analysis from position: 40
Branch analysis from position: 24
Branch analysis from position: 34
Branch analysis from position: 28
Branch analysis from position: 43
filename:       /in/9hfVP
function name:  get_folders
number of ops:  45
compiled vars:  !0 = $path, !1 = $browsers, !2 = $handle, !3 = $current_dir, !4 = $entry, !5 = $browser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'is_dir'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        BOOL_NOT                                         ~7      $6
          5      > JMPZ                                                     ~7, ->11
   37     6    >   ROPE_INIT                                     3  ~9      'ERROR%3A+'
          7        ROPE_ADD                                      1  ~9      ~9, !0
          8        ROPE_END                                      2  ~8      ~9, '+isn%27t+a+directory.+Please+provide+valid+directory+for+path.%0A'
          9        ECHO                                                     ~8
   38    10      > EXIT                                                     
   41    11    >   ASSIGN                                                   !1, <array>
   42    12        INIT_FCALL                                               'opendir'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $12     
         15        ASSIGN                                           ~13     !2, $12
         16      > JMPZ                                                     ~13, ->43
   43    17    >   INIT_FCALL                                               'chdir'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
   44    20        INIT_FCALL                                               'getcwd'
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !3, $15
   46    23      > JMP                                                      ->34
   47    24    >   IS_NOT_EQUAL                                     ~17     !4, '.'
         25      > JMPZ_EX                                          ~17     ~17, ->28
         26    >   IS_NOT_EQUAL                                     ~18     !4, '..'
         27        BOOL                                             ~17     ~18
         28    > > JMPZ                                                     ~17, ->34
   48    29    >   CONCAT                                           ~19     !3, '%2F'
         30        CONCAT                                           ~20     ~19, !4
         31        ASSIGN                                                   !5, ~20
   49    32        ASSIGN_DIM                                               !1
         33        OP_DATA                                                  !5
   46    34    >   INIT_FCALL                                               'readdir'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $23     
         37        ASSIGN                                           ~24     !4, $23
         38        TYPE_CHECK                                  1018          ~24
         39      > JMPNZ                                                    ~25, ->24
   52    40    >   INIT_FCALL                                               'closedir'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                                 
   54    43    > > RETURN                                                   !1
   55    44*     > RETURN                                                   null

End of function get_folders

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.32 ms | 1404 KiB | 37 Q