3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo get_fraction(3.4); function get_fraction($decimal){ $decimal_array = explode( $decimal, '.'); $whole_number = $decimal_array[0]; $decimal_number = $decimal_array[1]; $multiplier = "1"; for ($i = 0; $i < strlen($decimal_number); $i++) { $multiplier .= '0'; } $multiplier = int($multiplier); $decimal_int = $multiplier * $decimal_number; for ($i = 2; $i < $decimal_int; $i++) { if( $decimal_int % $i == 0 && $multiplier % i == 0){ $decimal_int = $decimal_int / $i; $multiplier = $multiplier / $i; } // code... } if( $decimal_int){ if( $whole_number){ return $whole_number . ' ' . $decimal_int . '/' . $multiplier; }else{ return $decimal_int . '/' . $multiplier; } }else{ return $whole_number; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQBlu
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'get_fraction'
          1        SEND_VAL_EX                                              3.4
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   36     4      > RETURN                                                   1

Function get_fraction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 26
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 26
Branch analysis from position: 41
Branch analysis from position: 26
Branch analysis from position: 38
Branch analysis from position: 33
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 13
Branch analysis from position: 18
Branch analysis from position: 13
filename:       /in/nQBlu
function name:  get_fraction
number of ops:  55
compiled vars:  !0 = $decimal, !1 = $decimal_array, !2 = $whole_number, !3 = $decimal_number, !4 = $multiplier, !5 = $i, !6 = $decimal_int
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'explode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '.'
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
    7     6        FETCH_DIM_R                                      ~9      !1, 0
          7        ASSIGN                                                   !2, ~9
    8     8        FETCH_DIM_R                                      ~11     !1, 1
          9        ASSIGN                                                   !3, ~11
   10    10        ASSIGN                                                   !4, '1'
   11    11        ASSIGN                                                   !5, 0
         12      > JMP                                                      ->15
   12    13    >   ASSIGN_OP                                     8          !4, '0'
   11    14        PRE_INC                                                  !5
         15    >   STRLEN                                           ~17     !3
         16        IS_SMALLER                                               !5, ~17
         17      > JMPNZ                                                    ~18, ->13
   14    18    >   INIT_FCALL_BY_NAME                                       'int'
         19        SEND_VAR_EX                                              !4
         20        DO_FCALL                                      0  $19     
         21        ASSIGN                                                   !4, $19
   15    22        MUL                                              ~21     !4, !3
         23        ASSIGN                                                   !6, ~21
   17    24        ASSIGN                                                   !5, 2
         25      > JMP                                                      ->39
   18    26    >   MOD                                              ~24     !6, !5
         27        IS_EQUAL                                         ~25     ~24, 0
         28      > JMPZ_EX                                          ~25     ~25, ->33
         29    >   FETCH_CONSTANT                                   ~26     'i'
         30        MOD                                              ~27     !4, ~26
         31        IS_EQUAL                                         ~28     ~27, 0
         32        BOOL                                             ~25     ~28
         33    > > JMPZ                                                     ~25, ->38
   19    34    >   DIV                                              ~29     !6, !5
         35        ASSIGN                                                   !6, ~29
   20    36        DIV                                              ~31     !4, !5
         37        ASSIGN                                                   !4, ~31
   17    38    >   PRE_INC                                                  !5
         39    >   IS_SMALLER                                               !5, !6
         40      > JMPNZ                                                    ~34, ->26
   24    41    > > JMPZ                                                     !6, ->53
   25    42    > > JMPZ                                                     !2, ->49
   26    43    >   CONCAT                                           ~35     !2, '+'
         44        CONCAT                                           ~36     ~35, !6
         45        CONCAT                                           ~37     ~36, '%2F'
         46        CONCAT                                           ~38     ~37, !4
         47      > RETURN                                                   ~38
         48*       JMP                                                      ->52
   28    49    >   CONCAT                                           ~39     !6, '%2F'
         50        CONCAT                                           ~40     ~39, !4
         51      > RETURN                                                   ~40
         52*       JMP                                                      ->54
   32    53    > > RETURN                                                   !2
   36    54*     > RETURN                                                   null

End of function get_fraction

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158 ms | 1400 KiB | 15 Q