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'); $ret.=chr($shit[$i]); } return $ret; } $str="the quick brown fox jumps over the lazy dog こどものじかん"; var_dump($str,encode($str),decode(encode($str)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vPPk1
function name:  (null)
number of ops:  16
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     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'
   28     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        INIT_FCALL                                               'encode'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        INIT_FCALL                                               'decode'
          8        INIT_FCALL                                               'encode'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $3      
         11        SEND_VAR                                                 $3
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
         15      > 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/vPPk1
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 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 12
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 12
Branch analysis from position: 30
Branch analysis from position: 12
filename:       /in/vPPk1
function name:  decode
number of ops:  32
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                                                      ->28
   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        INIT_FCALL                                               'chr'
         23        FETCH_DIM_R                                      ~20     !5, !2
         24        SEND_VAL                                                 ~20
         25        DO_ICALL                                         $21     
         26        ASSIGN_OP                                     8          !1, $21
   20    27        ASSIGN_OP                                     1          !2, 4
         28    >   IS_SMALLER                                               !2, !4
         29      > JMPNZ                                                    ~24, ->12
   24    30    > > RETURN                                                   !1
   26    31*     > RETURN                                                   null

End of function decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
234.86 ms | 1402 KiB | 28 Q