3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Math { const pi = 3.14; } class CircleMath extends Math { public static function calculateArea($radius) { return parent::pi * pow($radius, 2); } } class Circle { private $radius = 1.0; private $color = 'white'; private $coordinates = array('x' => 0, 'y' => 0); public function __construct() { $args = func_get_args(); for ($args as $arg) { if (is_numeric($arg)) { $this->radius = doubleval($arg); } else if (is_string($arg)) { $this->color = $arg; } else if (is_array()) { $this->coordinates = $arg; } } } public function calculateArea() { return CircleMath::calculateArea($this->radius); } public function get_radius() { return $this->radius; } public function get_color() { return $this->color; } public function get_coordinates() { return $this->coordinates; } } $className = 'Circle'; $circle = new $className(); print sprintf('The area of %s circle with radius %s and center positioned in (%s, %s) is: %s', $circle->get_color(), $circle->get_radius(), $circle->get_coordinates()['x'], $circle->get_coordinates()['y'], $circle->calculateArea()); ?>
Output for 5.4.0 - 5.4.21
Parse error: syntax error, unexpected 'as' (T_AS), expecting ';' in /in/HUTQh on line 21
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_AS, expecting ';' in /in/HUTQh on line 21
Process exited with code 255.