public static function http_error($errno = 500, $message = '', $layout = true): bool
    {
        $http_codes = array(
            400 => 'Bad Request',
            401 => 'Unauthorized',
            402 => 'Payment Required',
            403 => 'Forbidden',
            404 => 'Not Found',
            405 => 'Method Not Allowed',
            406 => 'Not Acceptable',
            407 => 'Proxy Authentication Required',
            408 => 'Request Timeout',
            409 => 'Conflict',
            410 => 'Gone',
            411 => 'Length Required',
            412 => 'Precondition Failed',
            413 => 'Request Entity Too Large',
            414 => 'Request-URI Too Long',
            415 => 'Unsupported Media Type',
            416 => 'Requested Range Not Satisfiable',
            417 => 'Expectation Failed',
            418 => 'I\'m a teapot',
            426 => 'Upgrade Required',
            428 => 'Precondition Required',
            429 => 'Too Many Requests',
            431 => 'Request Header Fields Too Large',
            500 => 'Internal Server Error',
            501 => 'Not Implemented',
            502 => 'Bad Gateway',
            503 => 'Service Unavailable',
            504 => 'Gateway Timeout',
            505 => 'HTTP Version Not Supported',
            506 => 'Variant Also Negotiates',
            509 => 'Bandwidth Limit Exceeded',
            510 => 'Not Extended',
            511 => 'Network Authentication Required',
        );

        self::logError('HTTP-error ' . $errno . ' called');
        self::log('Sending header HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);
        header('HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);

        // Set the status code
        Core::$http_status_code = $errno;

        // Do we want the error-layout with it?
        if ($layout == false) {
            return false;
        }

        // Load the layout
        $layout = 'errors/' . $errno;
        self::log('Loading layout ' . $layout);

        // Try and load the layout, if impossible, load HTTP code instead.
        $factory = Factory::getInstance();
        try {
            $factory->layout->reset();
            $factory->layout->assign('httpErrorMessage', $message);
            $factory->layout->display($layout);
        } catch (LayoutException $exception) {
            // No error page could be found, just echo the result
            $factory->output->set_output("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3><p>' . $message . '</p>');
        }
        
        return true;
    }
public static function http_error($errno = 500, $message = '', $layout = true): bool
    {
        $http_codes = array(
            400 => 'Bad Request',
            401 => 'Unauthorized',
            402 => 'Payment Required',
            403 => 'Forbidden',
            404 => 'Not Found',
            405 => 'Method Not Allowed',
            406 => 'Not Acceptable',
            407 => 'Proxy Authentication Required',
            408 => 'Request Timeout',
            409 => 'Conflict',
            410 => 'Gone',
            411 => 'Length Required',
            412 => 'Precondition Failed',
            413 => 'Request Entity Too Large',
            414 => 'Request-URI Too Long',
            415 => 'Unsupported Media Type',
            416 => 'Requested Range Not Satisfiable',
            417 => 'Expectation Failed',
            418 => 'I\'m a teapot',
            426 => 'Upgrade Required',
            428 => 'Precondition Required',
            429 => 'Too Many Requests',
            431 => 'Request Header Fields Too Large',
            500 => 'Internal Server Error',
            501 => 'Not Implemented',
            502 => 'Bad Gateway',
            503 => 'Service Unavailable',
            504 => 'Gateway Timeout',
            505 => 'HTTP Version Not Supported',
            506 => 'Variant Also Negotiates',
            509 => 'Bandwidth Limit Exceeded',
            510 => 'Not Extended',
            511 => 'Network Authentication Required',
        );

        self::logError('HTTP-error ' . $errno . ' called');
        self::log('Sending header HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);
        header('HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]);

        // Set the status code
        Core::$http_status_code = $errno;

        // Do we want the error-layout with it?
        if ($layout == false) {
            return false;
        }

        // Load the layout
        $layout = 'errors/' . $errno;
        self::log('Loading layout ' . $layout);

        // Try and load the layout, if impossible, load HTTP code instead.
        $factory = Factory::getInstance();
        try {
            $factory->layout->reset();
            $factory->layout->assign('httpErrorMessage', $message);
            $factory->layout->display($layout);
        } catch (LayoutException $exception) {
            // No error page could be found, just echo the result
            $factory->output->set_output("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3><p>' . $message . '</p>');
        }
        
        return true;
    }
public static function http_error ( $ errno = 500 , $ message = '' , $ layout = true ) : bool { $ http_codes = array ( 400 => 'Bad Request' , 401 => 'Unauthorized' , 402 => 'Payment Required' , 403 => 'Forbidden' , 404 => 'Not Found' , 405 => 'Method Not Allowed' , 406 => 'Not Acceptable' , 407 => 'Proxy Authentication Required' , 408 => 'Request Timeout' , 409 => 'Conflict' , 410 => 'Gone' , 411 => 'Length Required' , 412 => 'Precondition Failed' , 413 => 'Request Entity Too Large' , 414 => 'Request-URI Too Long' , 415 => 'Unsupported Media Type' , 416 => 'Requested Range Not Satisfiable' , 417 => 'Expectation Failed' , 418 => 'I\'m a teapot' , 426 => 'Upgrade Required' , 428 => 'Precondition Required' , 429 => 'Too Many Requests' , 431 => 'Request Header Fields Too Large' , 500 => 'Internal Server Error' , 501 => 'Not Implemented' , 502 => 'Bad Gateway' , 503 => 'Service Unavailable' , 504 => 'Gateway Timeout' , 505 => 'HTTP Version Not Supported' , 506 => 'Variant Also Negotiates' , 509 => 'Bandwidth Limit Exceeded' , 510 => 'Not Extended' , 511 => 'Network Authentication Required' , ) ; self :: logError ( 'HTTP-error ' . $ errno . ' called' ) ; self :: log ( 'Sending header HTTP/1.1 ' . $ errno . ' ' . $ http_codes [ $ errno ] ) ; header ( 'HTTP/1.1 ' . $ errno . ' ' . $ http_codes [ $ errno ] ) ; // Set the status code Core :: $ http_status_code = $ errno ; // Do we want the error-layout with it? if ( $ layout == false ) { return false ; } // Load the layout $ layout = 'errors/' . $ errno ; self :: log ( 'Loading layout ' . $ layout ) ; // Try and load the layout, if impossible, load HTTP code instead. $ factory = Factory :: getInstance ( ) ; try { $ factory -> layout -> reset ( ) ; $ factory -> layout -> assign ( 'httpErrorMessage' , $ message ) ; $ factory -> layout -> display ( $ layout ) ; } catch ( LayoutException $ exception ) { // No error page could be found, just echo the result $ factory -> output -> set_output ( "<h1>$errno</h1><h3>" . $ http_codes [ $ errno ] . '</h3><p>' . $ message . '</p>' ) ; } return true ; }
Calls an HTTP error, sends it as a header, and loads a template if required to do so.

@param int       $errno      HTTP error code
@param string    $message    Message describing the reason for the HTTP error
@param bool      $layout     true to layout error on website
Calls an HTTP error sends it as a header and loads a template if required to do so .