3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); // Would also need the same code for BaseError abstract class BaseException extends Exception { private static $codeReflection; private function setCode(string $code) { if (!isset(self::$codeReflection)) { self::$codeReflection = new ReflectionProperty(self::class, 'code'); self::$codeReflection->setAccessible(true); } self::$codeReflection->setValue($this, $code); } public function __construct(string $message, string $code, \Throwable $previous = null) { parent::__construct($message, 0, $previous); $this->setCode($code); } } class DivisionByZeroException extends BaseException {} $e = new DivisionByZeroException("Test", 'Test001'); var_dump($e->getMessage(), $e->getCode());
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "Test" string(7) "Test001"

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:
119.25 ms | 405 KiB | 5 Q