3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * * @author Kyle @ Iezon * @copyright (c) 2016 - 2017, Iezon * * Controller for Tax and Payments * **/ namespace Iezon\Products; class Item { public function __construct($product_id) { // load product from database } public function cost() { return 1000; } } class TaxReturn { const Tax = 0.2; const TaxPercent = 20; private $_total = 0; private $_item = []; public function __construct() { $stored = $_SESSION['total']; if(empty($stored)) return; $this->_total = $stored; } public function append(Item $item) { $this->_item[] = $item; $this->_total = $this->_total + $item->cost(); return $this; } public function retrieve() { return [ 'total' => $this->_total, 'tax_total' => (($this->_total / 100) * self::Tax) + $this->_total ]; } } session_start(); $iezon = []; $iezon['payment'] = [ 'object' => new TaxReturn(), 'disclose' => [] ]; $iezon['payment']['object']->append(new Item('Some Id')); $iezon['payment']['disclose'] = $iezon['payment']['object']->retrieve(); $money = $iezon['payment']['disclose']['tax_total']; echo 'Total (' . TaxReturn::TaxPercent . '%) : ' . echo number_format(($money /100), 2, '.', ' ');

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)
7.1.00.0070.07322.40
7.0.130.0030.07322.11
7.0.120.0030.06022.00
7.0.110.0070.06322.08
7.0.100.0030.08022.13
7.0.90.0030.06022.19
7.0.80.0130.05022.00
7.0.70.0100.06021.95
7.0.60.0000.06721.80
7.0.50.0070.06021.99
7.0.40.0100.07022.17
7.0.30.0170.04722.05
7.0.20.0030.06322.16
7.0.10.0200.04722.11
7.0.00.0030.06322.04
5.6.280.0130.05321.14
5.6.270.0030.07021.12
5.6.260.0100.05721.09
5.6.250.0130.06721.04
5.6.240.0170.04721.17
5.6.230.0130.05320.75
5.6.220.0070.05721.11
5.6.210.0000.06021.01
5.6.200.0070.07020.90
5.6.190.0170.05320.79
5.6.180.0170.05020.87
5.6.170.0030.06721.09
5.6.160.0030.05720.87
5.6.150.0030.05720.88
5.6.140.0000.06321.04
5.6.130.0100.05021.04
5.6.120.0130.05020.79
5.6.110.0070.06320.86
5.6.100.0100.05721.04
5.6.90.0100.06020.77
5.6.80.0130.06320.39
5.6.70.0170.06020.43
5.6.60.0100.06720.43
5.6.50.0100.05720.12
5.6.40.0100.05320.26
5.6.30.0130.05020.40
5.6.20.0170.05720.11
5.6.10.0100.06020.14
5.6.00.0100.05720.45

preferences:
142.51 ms | 1394 KiB | 7 Q