3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Point { public $X; public $Y; function __construct($X, $Y) { $this->X = $X; $this->Y = $Y; } } $moves = 10; $mouseX = 200; $mouseY = 200; $point = new Point(300, 300); $startAngle = rand(0, 90); $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)/$moves; $lineWidthDiv = 0; foreach ( $angles as $angle ) { $lineWidthDiv += cos($angle*pi()/180); } $lineWidth = ($point->X - $mouseX)/$moves; $points = array(new Point($mouseX, $mouseY)); for ( $i=1; $i<=$moves; $i++ ) { $x = $points[$i-1]->X + $lineWidth; $y = $points[$i-1]->Y + $lineHeight; $points[] = new Point($x, $y); } var_dump($points);
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
array(11) { [0]=> object(Point)#2 (2) { ["X"]=> int(200) ["Y"]=> int(200) } [1]=> object(Point)#3 (2) { ["X"]=> int(210) ["Y"]=> int(210) } [2]=> object(Point)#4 (2) { ["X"]=> int(220) ["Y"]=> int(220) } [3]=> object(Point)#5 (2) { ["X"]=> int(230) ["Y"]=> int(230) } [4]=> object(Point)#6 (2) { ["X"]=> int(240) ["Y"]=> int(240) } [5]=> object(Point)#7 (2) { ["X"]=> int(250) ["Y"]=> int(250) } [6]=> object(Point)#8 (2) { ["X"]=> int(260) ["Y"]=> int(260) } [7]=> object(Point)#9 (2) { ["X"]=> int(270) ["Y"]=> int(270) } [8]=> object(Point)#10 (2) { ["X"]=> int(280) ["Y"]=> int(280) } [9]=> object(Point)#11 (2) { ["X"]=> int(290) ["Y"]=> int(290) } [10]=> object(Point)#12 (2) { ["X"]=> int(300) ["Y"]=> int(300) } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SLYWr on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SLYWr on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/SLYWr on line 4
Process exited with code 255.