3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Point { public $X; public $Y; function __construct($X, $Y) { $this->X = $X; $this->Y = $Y; } } $moves = 4; $mouseX = 0; $mouseY = 0; $point = new Point(400, 400); $startAngle = rand(0, 90); echo 'Angle = '.$startAngle."\r\n"; $angles = array($startAngle); for ( $i=1; $i<$moves; $i++ ) { $angles[$i] = $angles[$i-1] + (90 - 2*$startAngle)/($moves-1); } $lineHeightDiv = 0; foreach ( $angles as $angle ) { $lineHeightDiv += sin($angle*pi()/180); } $lineHeight = (($point->Y-$mouseY)/$lineHeightDiv)/$moves; echo 'LineHeight = '.$lineHeight."\r\n"; $lineWidthDiv = 0; foreach ( $angles as $angle ) { $lineWidthDiv += cos($angle*pi()/180); } $lineWidth = (($point->X-$mouseX)/$lineWidthDiv)/$moves; echo 'LineWidth = '.$lineWidth."\r\n"; $points = array(new Point($mouseX, $mouseY)); for ( $i=1; $i<=$moves; $i++ ) { $x = $points[$i-1]->X + $lineWidth*cos($angles[$i]); $y = $points[$i-1]->Y + $lineHeight*sin($angles[$i]); $points[] = new Point($x, $y); } var_dump($points);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 20
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 44
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 44
2 jumps found. (Code = 77) Position 1 = 55, Position 2 = 65
Branch analysis from position: 55
2 jumps found. (Code = 78) Position 1 = 56, Position 2 = 65
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 82
Branch analysis from position: 111
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 82
Branch analysis from position: 111
Branch analysis from position: 82
Branch analysis from position: 65
Branch analysis from position: 44
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 20
Branch analysis from position: 32
Branch analysis from position: 20
filename:       /in/9AY6I
function name:  (null)
number of ops:  115
compiled vars:  !0 = $moves, !1 = $mouseX, !2 = $mouseY, !3 = $point, !4 = $startAngle, !5 = $angles, !6 = $i, !7 = $lineHeightDiv, !8 = $angle, !9 = $lineHeight, !10 = $lineWidthDiv, !11 = $lineWidth, !12 = $points, !13 = $x, !14 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 4
   14     1        ASSIGN                                                   !1, 0
   15     2        ASSIGN                                                   !2, 0
   16     3        NEW                                              $18     'Point'
          4        SEND_VAL_EX                                              400
          5        SEND_VAL_EX                                              400
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $18
   19     8        INIT_FCALL                                               'rand'
          9        SEND_VAL                                                 0
         10        SEND_VAL                                                 90
         11        DO_ICALL                                         $21     
         12        ASSIGN                                                   !4, $21
   21    13        CONCAT                                           ~23     'Angle+%3D+', !4
         14        CONCAT                                           ~24     ~23, '%0D%0A'
         15        ECHO                                                     ~24
   23    16        INIT_ARRAY                                       ~25     !4
         17        ASSIGN                                                   !5, ~25
   24    18        ASSIGN                                                   !6, 1
         19      > JMP                                                      ->30
   25    20    >   SUB                                              ~29     !6, 1
         21        FETCH_DIM_R                                      ~30     !5, ~29
         22        MUL                                              ~31     !4, 2
         23        SUB                                              ~32     90, ~31
         24        SUB                                              ~33     !0, 1
         25        DIV                                              ~34     ~32, ~33
         26        ADD                                              ~35     ~30, ~34
         27        ASSIGN_DIM                                               !5, !6
         28        OP_DATA                                                  ~35
   24    29        PRE_INC                                                  !6
         30    >   IS_SMALLER                                               !6, !0
         31      > JMPNZ                                                    ~37, ->20
   28    32    >   ASSIGN                                                   !7, 0
   29    33      > FE_RESET_R                                       $39     !5, ->44
         34    > > FE_FETCH_R                                               $39, !8, ->44
   30    35    >   INIT_FCALL                                               'sin'
         36        INIT_FCALL                                               'pi'
         37        DO_ICALL                                         $40     
         38        MUL                                              ~41     !8, $40
         39        DIV                                              ~42     ~41, 180
         40        SEND_VAL                                                 ~42
         41        DO_ICALL                                         $43     
         42        ASSIGN_OP                                     1          !7, $43
   29    43      > JMP                                                      ->34
         44    >   FE_FREE                                                  $39
   32    45        FETCH_OBJ_R                                      ~45     !3, 'Y'
         46        SUB                                              ~46     ~45, !2
         47        DIV                                              ~47     ~46, !7
         48        DIV                                              ~48     ~47, !0
         49        ASSIGN                                                   !9, ~48
   34    50        CONCAT                                           ~50     'LineHeight+%3D+', !9
         51        CONCAT                                           ~51     ~50, '%0D%0A'
         52        ECHO                                                     ~51
   36    53        ASSIGN                                                   !10, 0
   37    54      > FE_RESET_R                                       $53     !5, ->65
         55    > > FE_FETCH_R                                               $53, !8, ->65
   38    56    >   INIT_FCALL                                               'cos'
         57        INIT_FCALL                                               'pi'
         58        DO_ICALL                                         $54     
         59        MUL                                              ~55     !8, $54
         60        DIV                                              ~56     ~55, 180
         61        SEND_VAL                                                 ~56
         62        DO_ICALL                                         $57     
         63        ASSIGN_OP                                     1          !10, $57
   37    64      > JMP                                                      ->55
         65    >   FE_FREE                                                  $53
   40    66        FETCH_OBJ_R                                      ~59     !3, 'X'
         67        SUB                                              ~60     ~59, !1
         68        DIV                                              ~61     ~60, !10
         69        DIV                                              ~62     ~61, !0
         70        ASSIGN                                                   !11, ~62
   42    71        CONCAT                                           ~64     'LineWidth+%3D+', !11
         72        CONCAT                                           ~65     ~64, '%0D%0A'
         73        ECHO                                                     ~65
   44    74        NEW                                              $66     'Point'
         75        SEND_VAR_EX                                              !1
         76        SEND_VAR_EX                                              !2
         77        DO_FCALL                                      0          
         78        INIT_ARRAY                                       ~68     $66
         79        ASSIGN                                                   !12, ~68
   45    80        ASSIGN                                                   !6, 1
         81      > JMP                                                      ->109
   46    82    >   SUB                                              ~71     !6, 1
         83        FETCH_DIM_R                                      ~72     !12, ~71
         84        FETCH_OBJ_R                                      ~73     ~72, 'X'
         85        INIT_FCALL                                               'cos'
         86        FETCH_DIM_R                                      ~74     !5, !6
         87        SEND_VAL                                                 ~74
         88        DO_ICALL                                         $75     
         89        MUL                                              ~76     !11, $75
         90        ADD                                              ~77     ~73, ~76
         91        ASSIGN                                                   !13, ~77
   47    92        SUB                                              ~79     !6, 1
         93        FETCH_DIM_R                                      ~80     !12, ~79
         94        FETCH_OBJ_R                                      ~81     ~80, 'Y'
         95        INIT_FCALL                                               'sin'
         96        FETCH_DIM_R                                      ~82     !5, !6
         97        SEND_VAL                                                 ~82
         98        DO_ICALL                                         $83     
         99        MUL                                              ~84     !9, $83
        100        ADD                                              ~85     ~81, ~84
        101        ASSIGN                                                   !14, ~85
   48   102        NEW                                              $88     'Point'
        103        SEND_VAR_EX                                              !13
        104        SEND_VAR_EX                                              !14
        105        DO_FCALL                                      0          
        106        ASSIGN_DIM                                               !12
        107        OP_DATA                                                  $88
   45   108        PRE_INC                                                  !6
        109    >   IS_SMALLER_OR_EQUAL                                      !6, !0
        110      > JMPNZ                                                    ~91, ->82
   51   111    >   INIT_FCALL                                               'var_dump'
        112        SEND_VAR                                                 !12
        113        DO_ICALL                                                 
        114      > RETURN                                                   1

Class Point:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9AY6I
function name:  __construct
number of ops:  7
compiled vars:  !0 = $X, !1 = $Y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN_OBJ                                               'X'
          3        OP_DATA                                                  !0
    9     4        ASSIGN_OBJ                                               'Y'
          5        OP_DATA                                                  !1
   10     6      > RETURN                                                   null

End of function __construct

End of class Point.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.75 ms | 1408 KiB | 23 Q