3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($to_encode){ $i=0; $len=strlen($to_encode); $ret=''; for($i=0;$i<$len;++$i){ $ret.=str_pad(ord($to_encode[$i]),4,"0",STR_PAD_LEFT);//4 should be enough for UTF-8, right? } return $ret; } function decode($numberstr){ $numberstr=(string)$numberstr; $ret=''; $i=0; $ii=0; $len=strlen($numberstr); $shit=''; $len2=null; for($i=0;$i<$len;$i+=4){ $shit=ltrim(substr($numberstr,$i,4),'0'); for($ii=0;$ii<strlen($shit);++$ii){ $ret.=chr($shit[$ii]); } } return $ret; } $str="the quick brown fox jumps over the lazy dog こどものじかん"; var_dump(encode($str));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eIROJ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 'the+quick+brown+fox+jumps+over+the+lazy+dog+%E3%81%93%E3%81%A9%E3%82%82%E3%81%AE%E3%81%98%E3%81%8B%E3%82%93'
   30     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'encode'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
Branch analysis from position: 7
filename:       /in/eIROJ
function name:  encode
number of ops:  23
compiled vars:  !0 = $to_encode, !1 = $i, !2 = $len, !3 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 0
    4     2        STRLEN                                           ~5      !0
          3        ASSIGN                                                   !2, ~5
    5     4        ASSIGN                                                   !3, ''
    6     5        ASSIGN                                                   !1, 0
          6      > JMP                                                      ->19
    7     7    >   INIT_FCALL                                               'str_pad'
          8        INIT_FCALL                                               'ord'
          9        FETCH_DIM_R                                      ~9      !0, !1
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                         $10     
         12        SEND_VAR                                                 $10
         13        SEND_VAL                                                 4
         14        SEND_VAL                                                 '0'
         15        SEND_VAL                                                 0
         16        DO_ICALL                                         $11     
         17        ASSIGN_OP                                     8          !3, $11
    6    18        PRE_INC                                                  !1
         19    >   IS_SMALLER                                               !1, !2
         20      > JMPNZ                                                    ~14, ->7
   10    21    > > RETURN                                                   !3
   11    22*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 12
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 24
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 12
Branch analysis from position: 36
Branch analysis from position: 12
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 24
Branch analysis from position: 33
Branch analysis from position: 24
filename:       /in/eIROJ
function name:  decode
number of ops:  38
compiled vars:  !0 = $numberstr, !1 = $ret, !2 = $i, !3 = $ii, !4 = $len, !5 = $shit, !6 = $len2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        CAST                                          6  ~7      !0
          2        ASSIGN                                                   !0, ~7
   14     3        ASSIGN                                                   !1, ''
   15     4        ASSIGN                                                   !2, 0
   16     5        ASSIGN                                                   !3, 0
   17     6        STRLEN                                           ~12     !0
          7        ASSIGN                                                   !4, ~12
   18     8        ASSIGN                                                   !5, ''
   19     9        ASSIGN                                                   !6, null
   20    10        ASSIGN                                                   !2, 0
         11      > JMP                                                      ->34
   21    12    >   INIT_FCALL                                               'ltrim'
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 4
         17        DO_ICALL                                         $17     
         18        SEND_VAR                                                 $17
         19        SEND_VAL                                                 '0'
         20        DO_ICALL                                         $18     
         21        ASSIGN                                                   !5, $18
   22    22        ASSIGN                                                   !3, 0
         23      > JMP                                                      ->30
   23    24    >   INIT_FCALL                                               'chr'
         25        FETCH_DIM_R                                      ~21     !5, !3
         26        SEND_VAL                                                 ~21
         27        DO_ICALL                                         $22     
         28        ASSIGN_OP                                     8          !1, $22
   22    29        PRE_INC                                                  !3
         30    >   STRLEN                                           ~25     !5
         31        IS_SMALLER                                               !3, ~25
         32      > JMPNZ                                                    ~26, ->24
   20    33    >   ASSIGN_OP                                     1          !2, 4
         34    >   IS_SMALLER                                               !2, !4
         35      > JMPNZ                                                    ~28, ->12
   26    36    > > RETURN                                                   !1
   28    37*     > RETURN                                                   null

End of function decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.86 ms | 1406 KiB | 27 Q