<?php
class HttpException extends \Exception
{
const HTTP_NOT_FOUND = 404;
const ERROR_404_RESPONSE = 'Page not found';
// One off error messages can use this method...
public static function notFound()
{
throw new static("Error code 404: " . static::ERROR_404_RESPONSE);
}
}
HttpException::notFound();
Fatal error: Uncaught HttpException: Error code 404: Page not found in /in/ttUTa:11
Stack trace:
#0 /in/ttUTa(15): HttpException::notFound()
#1 {main}
thrown in /in/ttUTa on line 11
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught HttpException: Error code 404: Page not found in /in/ttUTa:11
Stack trace:
#0 /in/ttUTa(15): HttpException::notFound()
#1 {main}
thrown in /in/ttUTa on line 11
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Uncaught exception 'HttpException' with message 'Error code 404: Page not found' in /in/ttUTa:11
Stack trace:
#0 /in/ttUTa(15): HttpException::notFound()
#1 {main}
thrown in /in/ttUTa on line 11
Process exited with code 255.