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

Class Point:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Na6j
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:
163.69 ms | 953 KiB | 22 Q