3v4l.org

run code in 300+ PHP versions simultaneously
<?php FUNCTION bin2text($bin_str) { $text_str = ''; $chars = EXPLODE("\n", CHUNK_SPLIT(STR_REPLACE("\n", '', $bin_str), 8)); $_I = COUNT($chars); FOR($i = 0; $i < $_I; $text_str .= CHR(BINDEC($chars[$i])), $i ); RETURN $text_str; } FUNCTION text2bin($txt_str) { $len = STRLEN($txt_str); $bin = ''; FOR($i = 0; $i < $len; $i ) { $bin .= STRLEN(DECBIN(ORD($txt_str[$i]))) < 8 ? STR_PAD(DECBIN(ORD($txt_str[$i])), 8, 0, STR_PAD_LEFT) : DECBIN(ORD($txt_str[$i])); } RETURN $bin; } PRINT text2bin('Isnt this cool?');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0Jv7t
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'text2bin'
          1        SEND_VAL                                                 'Isnt+this+cool%3F'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function bin2text:
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 = 20
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 20
Branch analysis from position: 30
Branch analysis from position: 20
filename:       /in/0Jv7t
function name:  bin2text
number of ops:  32
compiled vars:  !0 = $bin_str, !1 = $text_str, !2 = $chars, !3 = $_I, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    5     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%0A'
          4        INIT_FCALL                                               'chunk_split'
          5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '%0A'
          7        SEND_VAL                                                 ''
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        SEND_VAL                                                 8
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                         $8      
         15        ASSIGN                                                   !2, $8
    6    16        COUNT                                            ~10     !2
         17        ASSIGN                                                   !3, ~10
    7    18        ASSIGN                                                   !4, 0
         19      > JMP                                                      ->28
         20    >   INIT_FCALL                                               'chr'
         21        INIT_FCALL                                               'bindec'
         22        FETCH_DIM_R                                      ~13     !2, !4
         23        SEND_VAL                                                 ~13
         24        DO_ICALL                                         $14     
         25        SEND_VAR                                                 $14
         26        DO_ICALL                                         $15     
         27        ASSIGN_OP                                     8          !1, $15
         28    >   IS_SMALLER                                               !4, !3
         29      > JMPNZ                                                    ~17, ->20
    8    30    > > RETURN                                                   !1
    9    31*     > RETURN                                                   null

End of function bin2text

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

End of function text2bin

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.79 ms | 1406 KiB | 30 Q