3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace vo { class ValueObject implements JsonSerializable { private $value; public function __construct($value) { $this->value = $value; } public function jsonSerialize() { return $this->value; } } class Age extends ValueObject { public function __construct(int $value) { if ($value > 150) { throw new Exception('Age must be less than 150.'); } parent::__construct($email); } } } function Email(string $email) { class Email extends \vo\ValueObject { public function __construct(string $value) { $email = filter_var($value, FILTER_VALIDATE_EMAIL); if (false === $email) { throw new Exception('Email is invalid.'); } parent::__construct($email); } } return new Email($value); } function Age(int $age) { return new \vo\Age($value); } // class User implements JsonSerializable { // private $email; // private $age; // public function __construct(Email $email) { // $this->email = $email; // } // public function setAge(Age $age) { $this->age = $age; } // public function jsonSerialize() { // return ['email' => $this->email, 'age' => $this->age]; // } // public function __destruct() // { // // persist // } // } // class UpdateUserCommand { // private $userId; // private $email; // private $age; // private $location; // public function __construct(GUID $userId, Email $email, Age $age = null, Point $location = null) { // $this->userId = $userId; // $this->email = $email; // $this->age = $age; // $this->location = $location; // } // public function getUserId() { return $this->userId; } // public function getEmail() { return $this->email; } // public function getAge() { return $this->age; } // public function getLocation() { return $this->location; } // } // class UserService { // private $users; // public function __construct(Users $users) { // $this->users = $users; // } // public function update(UpdateUserCommand $command) { // $user = $this->users[$command->getUserId()]; // $user->setEmail($command->getEmail()); // $user->setAge($command->getAge()); // $user->setPoint($command->getPoint()); // } // } $email = Email('opexus@gmail.com'); $age = Age(23); // $lattitude = new Lattitude(-20); // $longitude = new Longitude(170); // $point = new Point($lattitude, $longitude); // $user = new User($email); // $user->setAge($age); echo json_encode(compact('email', 'age'));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.6.150.0030.06718.23
5.6.140.0000.06318.12
5.6.130.0130.07318.25
5.6.120.0030.04021.13
5.6.110.0030.07021.13
5.6.100.0130.07321.13
5.6.90.0200.08020.98
5.6.80.0200.08020.55
5.5.300.0070.07318.07
5.5.290.0000.04717.98
5.5.280.0070.06720.98
5.5.270.0030.04320.66
5.5.260.0170.07020.83
5.5.250.0100.06320.71
5.5.240.0030.08020.20

preferences:
147.41 ms | 1394 KiB | 7 Q