Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php try { throw new RuntimeException("Database connection failed", 503); } catch (RuntimeException $e) { echo $e->getMessage(); // "Database connection failed" echo $e->getCode(); // 503 echo $e->getFile(); // Path to the file echo $e->getLine(); // Line number echo $e->getTraceAsString(); // Stack trace // For API responses http_response_code($e->getCode()); echo json_encode(["error" => $e->getMessage()]); }
Result
Open