3v4l.org

run code in 300+ PHP versions simultaneously
<?php function evalJS($code) { $matches = []; $code = preg_match_all('#var (.*)( |=|;)#', '\$', $code, $matches); foreach($matches[1] as $val) { $code = preg_replace('#'.$val.'#', '\$'.$val, $code); $code = preg_replace('#var \$'.$val.'#', '\$'.$val, $code); $code = preg_replace('#\$'.$val.'\.#', '\$'.$val.'->', $code); } $code = preg_replace('#.#', '::', $code); $code = preg_replace('#(\'|")\+#', '$1.', $code); $code = preg_replace('#\+(\'|")#', '.$1', $code); echo($code); eval($code); } class document { public function print($arg) { echo($arg); } } $js = <<<JS var foo = 'Hello '+'World!'; document.print(foo); JS; evalJS($js);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KofS6
function name:  (null)
number of ops:  5
compiled vars:  !0 = $js
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 'var+foo+%3D+%27Hello+%27%2B%27World%21%27%3B%0Adocument.print%28foo%29%3B'
   30     1        INIT_FCALL                                               'evaljs'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function evaljs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 41
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 41
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/KofS6
function name:  evalJS
number of ops:  63
compiled vars:  !0 = $code, !1 = $matches, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAL                                                 '%23var+%28.%2A%29%28+%7C%3D%7C%3B%29%23'
          4        SEND_VAL                                                 '%5C%24'
          5        SEND_REF                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !0, $4
    6     9        FETCH_DIM_R                                      ~6      !1, 1
         10      > FE_RESET_R                                       $7      ~6, ->41
         11    > > FE_FETCH_R                                               $7, !2, ->41
    8    12    >   INIT_FCALL                                               'preg_replace'
         13        CONCAT                                           ~8      '%23', !2
         14        CONCAT                                           ~9      ~8, '%23'
         15        SEND_VAL                                                 ~9
         16        CONCAT                                           ~10     '%5C%24', !2
         17        SEND_VAL                                                 ~10
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $11     
         20        ASSIGN                                                   !0, $11
    9    21        INIT_FCALL                                               'preg_replace'
         22        CONCAT                                           ~13     '%23var+%5C%24', !2
         23        CONCAT                                           ~14     ~13, '%23'
         24        SEND_VAL                                                 ~14
         25        CONCAT                                           ~15     '%5C%24', !2
         26        SEND_VAL                                                 ~15
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !0, $16
   10    30        INIT_FCALL                                               'preg_replace'
         31        CONCAT                                           ~18     '%23%5C%24', !2
         32        CONCAT                                           ~19     ~18, '%5C.%23'
         33        SEND_VAL                                                 ~19
         34        CONCAT                                           ~20     '%5C%24', !2
         35        CONCAT                                           ~21     ~20, '-%3E'
         36        SEND_VAL                                                 ~21
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                         $22     
         39        ASSIGN                                                   !0, $22
    6    40      > JMP                                                      ->11
         41    >   FE_FREE                                                  $7
   12    42        INIT_FCALL                                               'preg_replace'
         43        SEND_VAL                                                 '%23.%23'
         44        SEND_VAL                                                 '%3A%3A'
         45        SEND_VAR                                                 !0
         46        DO_ICALL                                         $24     
         47        ASSIGN                                                   !0, $24
   13    48        INIT_FCALL                                               'preg_replace'
         49        SEND_VAL                                                 '%23%28%27%7C%22%29%5C%2B%23'
         50        SEND_VAL                                                 '%241.'
         51        SEND_VAR                                                 !0
         52        DO_ICALL                                         $26     
         53        ASSIGN                                                   !0, $26
   14    54        INIT_FCALL                                               'preg_replace'
         55        SEND_VAL                                                 '%23%5C%2B%28%27%7C%22%29%23'
         56        SEND_VAL                                                 '.%241'
         57        SEND_VAR                                                 !0
         58        DO_ICALL                                         $28     
         59        ASSIGN                                                   !0, $28
   15    60        ECHO                                                     !0
   16    61        INCLUDE_OR_EVAL                                          !0, EVAL
   17    62      > RETURN                                                   null

End of function evaljs

Class document:
Function print:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KofS6
function name:  print
number of ops:  3
compiled vars:  !0 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ECHO                                                     !0
   23     2      > RETURN                                                   null

End of function print

End of class document.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.32 ms | 1403 KiB | 18 Q