3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source = json_encode([new StdClass, "This is a test", "Foo's bar", 1, 5]); $escaped = implode("", array_map(function($char) { if (ctype_alnum($char)) { return $char; } $bytelen = mb_strlen($char, '8bit'); if ($bytelen === 1) { return '\\x' . str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); } $result = '\\u'; for ($i = 0; $i < $bytelen; $i++) { $result .= str_pad(dechex(ord($char[$i])), 2, '0', STR_PAD_LEFT); } return $result; }, str_split($source, 1))); var_dump($escaped);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bs0Qe
function name:  (null)
number of ops:  29
compiled vars:  !0 = $source, !1 = $escaped
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_encode'
          1        NEW                                              $2      'StdClass'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~4      $2
          4        ADD_ARRAY_ELEMENT                                ~4      'This+is+a+test'
          5        ADD_ARRAY_ELEMENT                                ~4      'Foo%27s+bar'
          6        ADD_ARRAY_ELEMENT                                ~4      1
          7        ADD_ARRAY_ELEMENT                                ~4      5
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
    5    11        INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 ''
         13        INIT_FCALL                                               'array_map'
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fbs0Qe%3A5%240'
   19    15        SEND_VAL                                                 ~7
         16        INIT_FCALL                                               'str_split'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                         $9      
         22        SEND_VAR                                                 $9
         23        DO_ICALL                                         $10     
    5    24        ASSIGN                                                   !1, $10
   21    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fbs0Qe%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 30
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 30
Branch analysis from position: 47
Branch analysis from position: 30
filename:       /in/bs0Qe
function name:  {closure}
number of ops:  49
compiled vars:  !0 = $char, !1 = $bytelen, !2 = $result, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'ctype_alnum'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4      > JMPZ                                                     $4, ->6
    7     5    > > RETURN                                                   !0
    9     6    >   INIT_FCALL                                               'mb_strlen'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 '8bit'
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !1, $5
   11    11        IS_IDENTICAL                                             !1, 1
         12      > JMPZ                                                     ~7, ->27
   12    13    >   INIT_FCALL                                               'str_pad'
         14        INIT_FCALL                                               'dechex'
         15        INIT_FCALL                                               'ord'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        SEND_VAL                                                 2
         22        SEND_VAL                                                 '0'
         23        SEND_VAL                                                 0
         24        DO_ICALL                                         $10     
         25        CONCAT                                           ~11     '%5Cx', $10
         26      > RETURN                                                   ~11
   14    27    >   ASSIGN                                                   !2, '%5Cu'
   15    28        ASSIGN                                                   !3, 0
         29      > JMP                                                      ->45
   16    30    >   INIT_FCALL                                               'str_pad'
         31        INIT_FCALL                                               'dechex'
         32        INIT_FCALL                                               'ord'
         33        FETCH_DIM_R                                      ~14     !0, !3
         34        SEND_VAL                                                 ~14
         35        DO_ICALL                                         $15     
         36        SEND_VAR                                                 $15
         37        DO_ICALL                                         $16     
         38        SEND_VAR                                                 $16
         39        SEND_VAL                                                 2
         40        SEND_VAL                                                 '0'
         41        SEND_VAL                                                 0
         42        DO_ICALL                                         $17     
         43        ASSIGN_OP                                     8          !2, $17
   15    44        PRE_INC                                                  !3
         45    >   IS_SMALLER                                               !3, !1
         46      > JMPNZ                                                    ~20, ->30
   18    47    > > RETURN                                                   !2
   19    48*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fbs0Qe%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.82 ms | 1400 KiB | 33 Q