3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ECommerce { use Exception; class CreditCardValidationException extends Exception { } class CreditCardNumber { private $digits; public function __construct($digits) { $this->digits = $digits; if (!$this->_validate()) { throw new CreditCardValidationException('Checksum failed'); } } private function _validate() { for($i=0,$t=0;$i<16;$i+=2) $t+=(($d=((int)$this->digits{$i}*2))>9?array_sum(array_map('intval',str_split(strval($d)))):$d)+$this->digits{$i+1}; return(bool)($t%10===0); } } } namespace { try { $ccn = new ECommerce\CreditCardNumber('4417123456789114'); } catch (ECommerce\CreditCardValidationException $exception) { echo 'Invalid credit card number'; } finally { var_dump(isset($exception)); echo 'DONE'; } }
Output for git.master, git.master_jit
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/A1MnN on line 17
Process exited with code 255.
Output for rfc.property-hooks
Parse error: syntax error, unexpected token "{" in /in/A1MnN on line 17
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.95 ms | 401 KiB | 8 Q