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

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