3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * A polyfill library with PHP 7's improved way of doing integer division * * @author Michael Cullum <m@michaelcullum.com> * @license http://www.opensource.org/licenses/mit-license.html MIT License * @copyright 2015 Michael Cullum */ namespace { if (!function_exists('intdiv')) { function intdiv($dividend, $divisor) { $dividend = (int) $dividend; $divisor = (int) $divisor; if ($divisor === 0) { throw new DivisionByZeroError('Division by zero'); } if ($divisor === -1 && $dividend == ~PHP_INT_MAX) { throw new ArithmeticError('Division of PHP_INT_MIN by -1 is not an integer'); } $dividend = ($dividend - $dividend % $divisor); return ((int) ($dividend / $divisor)); } } if (!class_exists('ArithmeticError') || !class_exists('DivisionByZeroError')) { if (!class_exists('Throwable')) { class Throwable extends \Exception { public function __toString() { return $this->getMessage(); } } } if (!class_exists('Error')) { class Error extends Throwable { public function __toString() { return $this->getMessage(); } } } if (!class_exists('ArithmeticError')) { class ArithmeticError extends Error { public function __toString() { return $this->getMessage(); } } } if (!class_exists('DivisionByZeroError')) { class DivisionByZeroError extends Error { public function __toString() { return $this->getMessage(); } } } } foreach (array('Error', 'ArithmeticError', 'DivisionByZeroError') as $class) { print_r(class_implements($class)); if (!count(array_intersect(array('Exception', 'Throwable'), class_implements($class)))) { throw new \RuntimeException('A class named \''.$class.'\' is already defined that cannot be thrown.'); } } }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [Stringable] => Stringable [Throwable] => Throwable ) Array ( [Throwable] => Throwable [Stringable] => Stringable ) Array ( [Stringable] => Stringable [Throwable] => Throwable )

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:
58.63 ms | 401 KiB | 8 Q