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, '.', ' ');
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.13, 7.1.0
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/ECen5 on line 62
Process exited with code 255.

preferences:
185.84 ms | 1387 KiB | 51 Q