3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "Ваc зовут O\'reilly? \\/\\/\\"; function utf8_to_cp1251($s) { for ($c=0;$c<strlen($s);$c++) { $i=ord($s[$c]); if ($i<=127) $out.=$s[$c]; if ($byte2){ $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5; $new_i=$new_c1*256+$new_c2; if ($new_i==1025){ $out_i=168; } else { if ($new_i==1105){ $out_i=184; } else { $out_i=$new_i-848; } } $out.=chr($out_i); $byte2=false; } if (($i>>5)==6) { $c1=$i; $byte2=true; } } return $out; } echo utf8_to_cp1251($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6XGC
function name:  (null)
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%D0%92%D0%B0c+%D0%B7%D0%BE%D0%B2%D1%83%D1%82+O%5C%27reilly%3F+%5C%2F%5C%2F%5C'
   34     1        INIT_FCALL                                               'utf8_to_cp1251'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function utf8_to_cp1251:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 3
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 39
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 3
Branch analysis from position: 48
Branch analysis from position: 3
Branch analysis from position: 44
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
Branch analysis from position: 44
Branch analysis from position: 39
Branch analysis from position: 12
filename:       /in/L6XGC
function name:  utf8_to_cp1251
number of ops:  50
compiled vars:  !0 = $s, !1 = $c, !2 = $i, !3 = $out, !4 = $byte2, !5 = $new_c2, !6 = $c1, !7 = $new_c1, !8 = $new_i, !9 = $out_i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->45
    8     3    >   INIT_FCALL                                               'ord'
          4        FETCH_DIM_R                                      ~11     !0, !1
          5        SEND_VAL                                                 ~11
          6        DO_ICALL                                         $12     
          7        ASSIGN                                                   !2, $12
    9     8        IS_SMALLER_OR_EQUAL                                      !2, 127
          9      > JMPZ                                                     ~14, ->12
         10    >   FETCH_DIM_R                                      ~15     !0, !1
         11        ASSIGN_OP                                     8          !3, ~15
   10    12    > > JMPZ                                                     !4, ->39
   11    13    >   BW_AND                                           ~17     !6, 3
         14        MUL                                              ~18     ~17, 64
         15        BW_AND                                           ~19     !2, 63
         16        ADD                                              ~20     ~18, ~19
         17        ASSIGN                                                   !5, ~20
   12    18        SR                                               ~22     !6, 2
         19        BW_AND                                           ~23     ~22, 5
         20        ASSIGN                                                   !7, ~23
   13    21        MUL                                              ~25     !7, 256
         22        ADD                                              ~26     ~25, !5
         23        ASSIGN                                                   !8, ~26
   14    24        IS_EQUAL                                                 !8, 1025
         25      > JMPZ                                                     ~28, ->28
   15    26    >   ASSIGN                                                   !9, 168
         27      > JMP                                                      ->34
   17    28    >   IS_EQUAL                                                 !8, 1105
         29      > JMPZ                                                     ~30, ->32
   18    30    >   ASSIGN                                                   !9, 184
         31      > JMP                                                      ->34
   20    32    >   SUB                                              ~32     !8, 848
         33        ASSIGN                                                   !9, ~32
   23    34    >   INIT_FCALL                                               'chr'
         35        SEND_VAR                                                 !9
         36        DO_ICALL                                         $34     
         37        ASSIGN_OP                                     8          !3, $34
   24    38        ASSIGN                                                   !4, <false>
   26    39    >   SR                                               ~37     !2, 5
         40        IS_EQUAL                                                 ~37, 6
         41      > JMPZ                                                     ~38, ->44
   27    42    >   ASSIGN                                                   !6, !2
   28    43        ASSIGN                                                   !4, <true>
    6    44    >   PRE_INC                                                  !1
         45    >   STRLEN                                           ~42     !0
         46        IS_SMALLER                                               !1, ~42
         47      > JMPNZ                                                    ~43, ->3
   31    48    > > RETURN                                                   !3
   32    49*     > RETURN                                                   null

End of function utf8_to_cp1251

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.98 ms | 1403 KiB | 18 Q