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)/$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]*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 = 51, Position 2 = 61
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 61
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
2 jumps found. (Code = 44) Position 1 = 115, Position 2 = 78
Branch analysis from position: 115
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 115, Position 2 = 78
Branch analysis from position: 115
Branch analysis from position: 78
Branch analysis from position: 61
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/4qa6P
function name:  (null)
number of ops:  119
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        DIV                                              ~47     ~46, !0
         45        ASSIGN                                                   !9, ~47
   35    46        CONCAT                                           ~49     'LineHeight+%3D+', !9
         47        CONCAT                                           ~50     ~49, '%0D%0A'
         48        ECHO                                                     ~50
   37    49        ASSIGN                                                   !10, 0
   38    50      > FE_RESET_R                                       $52     !5, ->61
         51    > > FE_FETCH_R                                               $52, !8, ->61
   39    52    >   INIT_FCALL                                               'cos'
         53        INIT_FCALL                                               'pi'
         54        DO_ICALL                                         $53     
         55        MUL                                              ~54     !8, $53
         56        DIV                                              ~55     ~54, 180
         57        SEND_VAL                                                 ~55
         58        DO_ICALL                                         $56     
         59        ASSIGN_OP                                     1          !10, $56
   38    60      > JMP                                                      ->51
         61    >   FE_FREE                                                  $52
   41    62        FETCH_OBJ_R                                      ~58     !3, 'X'
         63        SUB                                              ~59     ~58, !1
         64        DIV                                              ~60     ~59, !10
         65        DIV                                              ~61     ~60, !0
         66        ASSIGN                                                   !11, ~61
   43    67        CONCAT                                           ~63     'LineWidth+%3D+', !11
         68        CONCAT                                           ~64     ~63, '%0D%0A'
         69        ECHO                                                     ~64
   45    70        NEW                                              $65     'Point'
         71        SEND_VAR_EX                                              !1
         72        SEND_VAR_EX                                              !2
         73        DO_FCALL                                      0          
         74        INIT_ARRAY                                       ~67     $65
         75        ASSIGN                                                   !12, ~67
   46    76        ASSIGN                                                   !6, 1
         77      > JMP                                                      ->113
   47    78    >   SUB                                              ~70     !6, 1
         79        FETCH_DIM_R                                      ~71     !12, ~70
         80        FETCH_OBJ_R                                      ~72     ~71, 'X'
         81        INIT_FCALL                                               'cos'
         82        FETCH_DIM_R                                      ~73     !5, !6
         83        INIT_FCALL                                               'pi'
         84        DO_ICALL                                         $74     
         85        MUL                                              ~75     $74, ~73
         86        DIV                                              ~76     ~75, 180
         87        SEND_VAL                                                 ~76
         88        DO_ICALL                                         $77     
         89        MUL                                              ~78     !11, $77
         90        ADD                                              ~79     ~72, ~78
         91        ASSIGN                                                   !13, ~79
   48    92        SUB                                              ~81     !6, 1
         93        FETCH_DIM_R                                      ~82     !12, ~81
         94        FETCH_OBJ_R                                      ~83     ~82, 'Y'
         95        INIT_FCALL                                               'sin'
         96        FETCH_DIM_R                                      ~84     !5, !6
         97        INIT_FCALL                                               'pi'
         98        DO_ICALL                                         $85     
         99        MUL                                              ~86     $85, ~84
        100        DIV                                              ~87     ~86, 180
        101        SEND_VAL                                                 ~87
        102        DO_ICALL                                         $88     
        103        MUL                                              ~89     !9, $88
        104        ADD                                              ~90     ~83, ~89
        105        ASSIGN                                                   !14, ~90
   49   106        NEW                                              $93     'Point'
        107        SEND_VAR_EX                                              !13
        108        SEND_VAR_EX                                              !14
        109        DO_FCALL                                      0          
        110        ASSIGN_DIM                                               !12
        111        OP_DATA                                                  $93
   46   112        PRE_INC                                                  !6
        113    >   IS_SMALLER_OR_EQUAL                                      !6, !0
        114      > JMPNZ                                                    ~96, ->78
   52   115    >   INIT_FCALL                                               'var_dump'
        116        SEND_VAR                                                 !12
        117        DO_ICALL                                                 
        118      > RETURN                                                   1

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