3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toFraction($number){ $numerator = 1; $denominator = 0; for(; $numerator < 1000; $numerator++){ $temp = $numerator / $number; if(ceil($temp) - $temp == 0){ $denominator = $temp; break; } } return ($denominator > 0) ? $numerator . '/' . $denominator : false; } echo toFraction( 0.5);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jKBkO
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'tofraction'
          1        SEND_VAL                                                 0.5
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function tofraction:
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 = 17, Position 2 = 4
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 4
Branch analysis from position: 17
Branch analysis from position: 4
filename:       /in/jKBkO
function name:  toFraction
number of ops:  26
compiled vars:  !0 = $number, !1 = $numerator, !2 = $denominator, !3 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 1
    4     2        ASSIGN                                                   !2, 0
    5     3      > JMP                                                      ->15
    6     4    >   DIV                                              ~6      !1, !0
          5        ASSIGN                                                   !3, ~6
    7     6        INIT_FCALL                                               'ceil'
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $8      
          9        SUB                                              ~9      $8, !3
         10        IS_EQUAL                                                 ~9, 0
         11      > JMPZ                                                     ~10, ->14
    8    12    >   ASSIGN                                                   !2, !3
    9    13      > JMP                                                      ->17
    5    14    >   PRE_INC                                                  !1
         15    >   IS_SMALLER                                               !1, 1000
         16      > JMPNZ                                                    ~13, ->4
   12    17    >   IS_SMALLER                                               0, !2
         18      > JMPZ                                                     ~14, ->23
         19    >   CONCAT                                           ~15     !1, '%2F'
         20        CONCAT                                           ~16     ~15, !2
         21        QM_ASSIGN                                        ~17     ~16
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~17     <false>
         24    > > RETURN                                                   ~17
   13    25*     > RETURN                                                   null

End of function tofraction

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.4 ms | 1403 KiB | 16 Q