3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $A = 1110; // $B = 370; // $C = 6171.6; // $H = 71.1; // $I = 556/$G; // Muss "4,21212121212121" ausgeben // $K = get_factor_K($I); // I wird benötigt. Gibt in diesem Beispiel "0,9942" aus // $L = get_factor_L($I); // I wird benötigt. Gibt in diesem Beispiel "0,998670248976177" aus // $G = $H/(545.223880597015/1000*$L*$K); // Aufrundung ohne Komma, muss "132" ausgeben // $J = $G*$B/1000*$A/100*1; // Muss "542,124" ausgeben // $D = ($C-$J); // Muss "5629,476" ausgeben // $E = ($I-$B/1000)*$A/100; // Muss "42,6475454545455" ausgeben // $F = $I*$A/100; // Muss "46,7545454545455" ausgeben function get_factor_k($i) { // Replace with correct code #return $i; return 0.9942; } function get_factor_l($i) { // Replace with correct code #return $i; return 0.998670248976177; } $a = 1110; $b = 370; $c = 6171.6; $h = 71.1; $i = 0.001; // undef $k = 0; // undef $l = 0; // undef $step = 0.001; // Auflösung für $i $i_max = 100; // um keine Endlosschleife zu produzieren $epsilon = 0.001; // Fehlertoleranz $found = false; do { $k = get_factor_k($i); $l = get_factor_l($i); $tmp = (556 / ($h / (545.223880597015 / 1000 * $k * $l))); $found = (abs($i - $tmp) <= $epsilon); if (!$found) { $i += $step; } if ($i > $i_max) { throw new Exception('Unable to calculate $i'); } } while (!$found); $g = ceil($h / (545.223880597015 / 1000 * $l * $k)); #$i = 556 / $g; // ??? $i haben wir schon $j = $g * $b / 1000 * $a / 100 * 1; $e = ($i - $b / 1000) * $a / 100; $f = $i * $a / 100; $d = $c - $j; foreach (range('a', 'l') as $var) { echo $var . ' = '; var_dump($$var); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 39
Branch analysis from position: 35
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 11
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 69, Position 2 = 77
Branch analysis from position: 69
2 jumps found. (Code = 78) Position 1 = 70, Position 2 = 77
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
Branch analysis from position: 11
Branch analysis from position: 33
filename:       /in/3il92
function name:  (null)
number of ops:  79
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $h, !4 = $i, !5 = $k, !6 = $l, !7 = $step, !8 = $i_max, !9 = $epsilon, !10 = $found, !11 = $tmp, !12 = $g, !13 = $j, !14 = $e, !15 = $f, !16 = $d, !17 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, 1110
   32     1        ASSIGN                                                   !1, 370
   33     2        ASSIGN                                                   !2, 6171.6
   35     3        ASSIGN                                                   !3, 71.1
   37     4        ASSIGN                                                   !4, 0.001
   38     5        ASSIGN                                                   !5, 0
   39     6        ASSIGN                                                   !6, 0
   41     7        ASSIGN                                                   !7, 0.001
   42     8        ASSIGN                                                   !8, 100
   43     9        ASSIGN                                                   !9, 0.001
   44    10        ASSIGN                                                   !10, <false>
   47    11    >   INIT_FCALL                                               'get_factor_k'
         12        SEND_VAR                                                 !4
         13        DO_FCALL                                      0  $29     
         14        ASSIGN                                                   !5, $29
   48    15        INIT_FCALL                                               'get_factor_l'
         16        SEND_VAR                                                 !4
         17        DO_FCALL                                      0  $31     
         18        ASSIGN                                                   !6, $31
   49    19        MUL                                              ~33     !5, 0.545224
         20        MUL                                              ~34     !6, ~33
         21        DIV                                              ~35     !3, ~34
         22        DIV                                              ~36     556, ~35
         23        ASSIGN                                                   !11, ~36
   51    24        INIT_FCALL                                               'abs'
         25        SUB                                              ~38     !4, !11
         26        SEND_VAL                                                 ~38
         27        DO_ICALL                                         $39     
         28        IS_SMALLER_OR_EQUAL                              ~40     $39, !9
         29        ASSIGN                                                   !10, ~40
   53    30        BOOL_NOT                                         ~42     !10
         31      > JMPZ                                                     ~42, ->33
   54    32    >   ASSIGN_OP                                     1          !4, !7
   57    33    >   IS_SMALLER                                               !8, !4
         34      > JMPZ                                                     ~44, ->39
   58    35    >   NEW                                              $45     'Exception'
         36        SEND_VAL_EX                                              'Unable+to+calculate+%24i'
         37        DO_FCALL                                      0          
         38      > THROW                                         0          $45
   60    39    >   BOOL_NOT                                         ~47     !10
         40      > JMPNZ                                                    ~47, ->11
   64    41    >   INIT_FCALL                                               'ceil'
         42        MUL                                              ~48     !6, 0.545224
         43        MUL                                              ~49     !5, ~48
         44        DIV                                              ~50     !3, ~49
         45        SEND_VAL                                                 ~50
         46        DO_ICALL                                         $51     
         47        ASSIGN                                                   !12, $51
   68    48        MUL                                              ~53     !12, !1
         49        DIV                                              ~54     ~53, 1000
         50        MUL                                              ~55     !0, ~54
         51        DIV                                              ~56     ~55, 100
         52        MUL                                              ~57     ~56, 1
         53        ASSIGN                                                   !13, ~57
   70    54        DIV                                              ~59     !1, 1000
         55        SUB                                              ~60     !4, ~59
         56        MUL                                              ~61     !0, ~60
         57        DIV                                              ~62     ~61, 100
         58        ASSIGN                                                   !14, ~62
   71    59        MUL                                              ~64     !4, !0
         60        DIV                                              ~65     ~64, 100
         61        ASSIGN                                                   !15, ~65
   73    62        SUB                                              ~67     !2, !13
         63        ASSIGN                                                   !16, ~67
   75    64        INIT_FCALL                                               'range'
         65        SEND_VAL                                                 'a'
         66        SEND_VAL                                                 'l'
         67        DO_ICALL                                         $69     
         68      > FE_RESET_R                                       $70     $69, ->77
         69    > > FE_FETCH_R                                               $70, !17, ->77
   76    70    >   CONCAT                                           ~71     !17, '+%3D+'
         71        ECHO                                                     ~71
   77    72        INIT_FCALL                                               'var_dump'
         73        FETCH_R                      local               ~72     !17
         74        SEND_VAL                                                 ~72
         75        DO_ICALL                                                 
   75    76      > JMP                                                      ->69
         77    >   FE_FREE                                                  $70
   78    78      > RETURN                                                   1

Function get_factor_k:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3il92
function name:  get_factor_k
number of ops:  3
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   21     1      > RETURN                                                   0.9942
   22     2*     > RETURN                                                   null

End of function get_factor_k

Function get_factor_l:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3il92
function name:  get_factor_l
number of ops:  3
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   28     1      > RETURN                                                   0.99867
   29     2*     > RETURN                                                   null

End of function get_factor_l

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.17 ms | 1406 KiB | 23 Q