3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MAX_ATTEMPTS', 5); class NetworkException extends Exception { } class FetchDataException extends Exception { private $surpressed = []; public function addSuppressed(Throwable $e): void { $this->surpressed[] = $e; } public function getSuppressed(): array { return $this->surpressed; } } function fetchDataOverNetwork() { $networkExceptions = []; for ($i = 0; $i < MAX_ATTEMPTS; $i++) { try { // Some operation that may throw throw new NetworkException(); } catch (NetworkException $ne) { $networkExceptions[] = $ne; } } $fdException = new FetchDataException("Failed to get data"); foreach ($networkExceptions as $networkException) { $fdException->addSuppressed($networkException); } throw $fdException; } try { fetchDataOverNetwork(); } catch(FetchDataException $fde) { var_dump($fde->getSuppressed()); }
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { [0]=> object(NetworkException)#1 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/cboHF" ["line":protected]=> int(26) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/cboHF" ["line"]=> int(43) ["function"]=> string(20) "fetchDataOverNetwork" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } [1]=> object(NetworkException)#2 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/cboHF" ["line":protected]=> int(26) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/cboHF" ["line"]=> int(43) ["function"]=> string(20) "fetchDataOverNetwork" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } [2]=> object(NetworkException)#3 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/cboHF" ["line":protected]=> int(26) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/cboHF" ["line"]=> int(43) ["function"]=> string(20) "fetchDataOverNetwork" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } [3]=> object(NetworkException)#4 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/cboHF" ["line":protected]=> int(26) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/cboHF" ["line"]=> int(43) ["function"]=> string(20) "fetchDataOverNetwork" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } [4]=> object(NetworkException)#5 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/cboHF" ["line":protected]=> int(26) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/cboHF" ["line"]=> int(43) ["function"]=> string(20) "fetchDataOverNetwork" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL } }

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:
132.31 ms | 416 KiB | 5 Q