3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function minimize($file) { return preg_replace('#(<\?php)\s+#S','$1 ',preg_replace('#\s*([(){}[\];,.:+<>*/%^=&?|$-])\s*#S', '$1', array_reduce(token_get_all(php_strip_whitespace($file)),function($c,$x){ static $s = [], $i=0; if ( is_string($x) ) return $c . $x; $_ = $x[1]; switch($x[0]){ case T_STRING: return $c . (defined($_) ? (is_bool($k=constant($_))||is_null($k)?$_:$k) : $_); case T_VARIABLE: return $c . (empty($s[$_]) ? ($s[$_] = '$_' . base_convert($i++,10,36)) : $s[$_]); case T_LOGICAL_OR: return $c . '||'; case T_LOGICAL_AND: return $c . '&&'; default: return $c . $_; } }))); } echo minimize(__FILE__);
based on 4f0Gi
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/pvOcX
function name:  (null)
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  18     1        INIT_FCALL                                               'minimize'
         2        SEND_VAL                                                 '%2Fin%2FpvOcX'
         3        DO_FCALL                                      0  $0      
         4        ECHO                                                     $0
         5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FpvOcX0x7f64701712a3:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
Jump found. Position 1 = -2
Branch analysis from position: 10
Jump found. Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
Jump found. Position 1 = 17, Position 2 = 44
Branch analysis from position: 17
Jump found. Position 1 = 19, Position 2 = 62
Branch analysis from position: 19
Jump found. Position 1 = 21, Position 2 = 65
Branch analysis from position: 21
Jump found. Position 1 = 68
Branch analysis from position: 68
Jump found. Position 1 = -2
Branch analysis from position: 65
Jump found. Position 1 = -2
Branch analysis from position: 62
Jump found. Position 1 = -2
Branch analysis from position: 44
Jump found. Position 1 = 46, Position 2 = 57
Branch analysis from position: 46
Jump found. Position 1 = 59
Branch analysis from position: 59
Jump found. Position 1 = -2
Branch analysis from position: 57
Jump found. Position 1 = -2
Branch analysis from position: 22
Jump found. Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
Jump found. Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
Jump found. Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
Jump found. Position 1 = 38
Branch analysis from position: 38
Jump found. Position 1 = 41
Branch analysis from position: 41
Jump found. Position 1 = -2
Branch analysis from position: 37
Jump found. Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 34
Branch analysis from position: 40
Jump found. Position 1 = -2
filename:       /in/pvOcX
function name:  {closure}
number of ops:  73
compiled vars:  !0 = $c, !1 = $x, !2 = $s, !3 = $i, !4 = $_, !5 = $k
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   RECV                                             !0      
         1        RECV                                             !1      
   6     2        FETCH_W                      static              $6      's'
         3        ASSIGN_REF                                               !2, $6
         4        FETCH_W                      static              $7      'i'
         5        ASSIGN_REF                                               !3, $7
   7     6        TYPE_CHECK                                    6  ~8      !1
         7      > JMPZ                                                     ~8, ->10
         8    >   CONCAT                                           ~9      !0, !1
         9      > RETURN                                                   ~9
        10    >   FETCH_DIM_R                                      $10     !1, 1
        11        ASSIGN                                                   !4, $10
   8    12        FETCH_DIM_R                                      $12     !1, 0
   9    13        CASE                                             ~13     $12, 319
        14      > JMPNZ                                                    ~13, ->22
  10    15    >   CASE                                             ~13     $12, 320
        16      > JMPNZ                                                    ~13, ->44
  11    17    >   CASE                                             ~13     $12, 263
        18      > JMPNZ                                                    ~13, ->62
  12    19    >   CASE                                             ~13     $12, 265
        20      > JMPNZ                                                    ~13, ->65
        21    > > JMP                                                      ->68
   9    22    >   INIT_FCALL                                               'defined'
        23        SEND_VAR                                                 !4
        24        DO_ICALL                                         $14     
        25      > JMPZ                                                     $14, ->40
        26    >   INIT_FCALL                                               'constant'
        27        SEND_VAR                                                 !4
        28        DO_ICALL                                         $15     
        29        ASSIGN                                           $16     !5, $15
        30        TYPE_CHECK                                   13  ~17     $16
        31      > JMPNZ_EX                                         ~17     ~17, ->34
        32    >   TYPE_CHECK                                    1  ~18     !5
        33        BOOL                                             ~17     ~18
        34    > > JMPZ                                                     ~17, ->37
        35    >   QM_ASSIGN                                        ~19     !4
        36      > JMP                                                      ->38
        37    >   QM_ASSIGN                                        ~19     !5
        38    >   QM_ASSIGN                                        ~20     ~19
        39      > JMP                                                      ->41
        40    >   QM_ASSIGN                                        ~20     !4
        41    >   CONCAT                                           ~21     !0, ~20
        42        FREE                                                     $12
        43      > RETURN                                                   ~21
  10    44    >   ISSET_ISEMPTY_DIM_OBJ                       16777216  ~22     !2, !4
        45      > JMPZ                                                     ~22, ->57
        46    >   INIT_FCALL                                               'base_convert'
        47        POST_INC                                         ~24     !3
        48        SEND_VAL                                                 ~24
        49        SEND_VAL                                                 10
        50        SEND_VAL                                                 36
        51        DO_ICALL                                         $25     
        52        CONCAT                                           ~26     '%24_', $25
        53        ASSIGN_DIM                                       $23     !2, !4
        54        OP_DATA                                                  ~26
        55        QM_ASSIGN                                        ~27     $23
        56      > JMP                                                      ->59
        57    >   FETCH_DIM_R                                      $28     !2, !4
        58        QM_ASSIGN                                        ~27     $28
        59    >   CONCAT                                           ~29     !0, ~27
        60        FREE                                                     $12
        61      > RETURN                                                   ~29
  11    62    >   CONCAT                                           ~30     !0, '%7C%7C'
        63        FREE                                                     $12
        64      > RETURN                                                   ~30
  12    65    >   CONCAT                                           ~31     !0, '%26%26'
        66        FREE                                                     $12
        67      > RETURN                                                   ~31
  13    68    >   CONCAT                                           ~32     !0, !4
        69        FREE                                                     $12
        70      > RETURN                                                   ~32
        71*       FREE                                                     $12
  15    72*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpvOcX0x7f64701712a3

Function minimize:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/pvOcX
function name:  minimize
number of ops:  24
compiled vars:  !0 = $file
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
   4     1        INIT_FCALL                                               'preg_replace'
         2        SEND_VAL                                                 '%23%28%3C%5C%3Fphp%29%5Cs%2B%23S'
         3        SEND_VAL                                                 '%241+'
         4        INIT_FCALL                                               'preg_replace'
         5        SEND_VAL                                                 '%23%5Cs%2A%28%5B%28%29%7B%7D%5B%5C%5D%3B%2C.%3A%2B%3C%3E%2A%2F%25%5E%3D%26%3F%7C%24-%5D%29%5Cs%2A%23S'
         6        SEND_VAL                                                 '%241'
         7        INIT_FCALL                                               'array_reduce'
         8        INIT_FCALL                                               'token_get_all'
         9        INIT_FCALL                                               'php_strip_whitespace'
        10        SEND_VAR                                                 !0
        11        DO_ICALL                                         $1      
        12        SEND_VAR                                                 $1
        13        DO_ICALL                                         $2      
        14        SEND_VAR                                                 $2
   5    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpvOcX0x7f64701712a3'
  15    16        SEND_VAL                                                 ~3
        17        DO_ICALL                                         $4      
        18        SEND_VAR                                                 $4
        19        DO_ICALL                                         $5      
        20        SEND_VAR                                                 $5
        21        DO_ICALL                                         $6      
        22      > RETURN                                                   $6
  16    23*     > RETURN                                                   null

End of function minimize

Generated using Vulcan Logic Dumper, using php 7.2.0