3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getMem() { return memory_get_usage(true) / 1024; } $array = range(1, 1000); shuffle($array); $mem = getMem(); $string = compress($array); echo 'You used : ', getMem() - $mem, ' Kb', PHP_EOL; function compress($array) { return gzdeflate(base64_encode(implode(',', $array)), 9); } function uncompress($data) { return explode(',', base64_decode(gzinflate($data))); } file_put_contents('demo', $string); $uncompress = uncompress($string); for ($i = 0; $i < 100; $i++) { $test = rand(0, 1000000 - 1); if ($array[$test] != $uncompress[$test]) { die('You failed!!!'); } } echo 'You Win', PHP_EOL; echo date('Y-m-d H:i:s'), PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 32
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 32
Branch analysis from position: 45
Branch analysis from position: 32
filename:       /in/NqO4W
function name:  (null)
number of ops:  53
compiled vars:  !0 = $array, !1 = $mem, !2 = $string, !3 = $uncompress, !4 = $i, !5 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 1000
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
    9     5        INIT_FCALL                                               'shuffle'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   10     8        INIT_FCALL                                               'getmem'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !1, $9
   11    11        INIT_FCALL_BY_NAME                                       'compress'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $11     
         14        ASSIGN                                                   !2, $11
   12    15        ECHO                                                     'You+used+%3A+'
         16        INIT_FCALL                                               'getmem'
         17        DO_FCALL                                      0  $13     
         18        SUB                                              ~14     $13, !1
         19        ECHO                                                     ~14
         20        ECHO                                                     '+Kb'
         21        ECHO                                                     '%0A'
   23    22        INIT_FCALL                                               'file_put_contents'
         23        SEND_VAL                                                 'demo'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
   24    26        INIT_FCALL                                               'uncompress'
         27        SEND_VAR                                                 !2
         28        DO_FCALL                                      0  $16     
         29        ASSIGN                                                   !3, $16
   26    30        ASSIGN                                                   !4, 0
         31      > JMP                                                      ->43
   27    32    >   INIT_FCALL                                               'rand'
         33        SEND_VAL                                                 0
         34        SEND_VAL                                                 999999
         35        DO_ICALL                                         $19     
         36        ASSIGN                                                   !5, $19
   28    37        FETCH_DIM_R                                      ~21     !0, !5
         38        FETCH_DIM_R                                      ~22     !3, !5
         39        IS_NOT_EQUAL                                             ~21, ~22
         40      > JMPZ                                                     ~23, ->42
   29    41    > > EXIT                                                     'You+failed%21%21%21'
   26    42    >   PRE_INC                                                  !4
         43    >   IS_SMALLER                                               !4, 100
         44      > JMPNZ                                                    ~25, ->32
   32    45    >   ECHO                                                     'You+Win'
         46        ECHO                                                     '%0A'
   33    47        INIT_FCALL                                               'date'
         48        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         49        DO_ICALL                                         $26     
         50        ECHO                                                     $26
         51        ECHO                                                     '%0A'
         52      > RETURN                                                   1

Function getmem:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NqO4W
function name:  getMem
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $0      
          3        DIV                                              ~1      $0, 1024
          4      > RETURN                                                   ~1
    6     5*     > RETURN                                                   null

End of function getmem

Function compress:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NqO4W
function name:  compress
number of ops:  14
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'gzdeflate'
          2        INIT_FCALL                                               'base64_encode'
          3        INIT_FCALL                                               'implode'
          4        SEND_VAL                                                 '%2C'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        SEND_VAL                                                 9
         11        DO_ICALL                                         $3      
         12      > RETURN                                                   $3
   17    13*     > RETURN                                                   null

End of function compress

Function uncompress:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NqO4W
function name:  uncompress
number of ops:  13
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2C'
          3        INIT_FCALL                                               'base64_decode'
          4        INIT_FCALL                                               'gzinflate'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                         $3      
         11      > RETURN                                                   $3
   21    12*     > RETURN                                                   null

End of function uncompress

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.15 ms | 1398 KiB | 40 Q