Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Error::getPreviousError::getFile>
^ErrorLast updated: Mon, 26 Oct 2026

Error::getCode

(PHP 7, PHP 8)

Error::getCode — Gets the error code

Description

final public function Error::getCode(): int

Returns the error code.

Parameters

This function has no parameters.

Return Values

Returns the error code as int

Examples

Example #1 Error::getCode() example

<?php
try {
    throw new Error("Some error message", 30);
} catch(Error $e) {
    echo "The Error code is: " . $e->getCode();
}
?>

The above example will output something similar to:

The Error code is: 30

See Also


<Error::getPreviousError::getFile>
^ErrorLast updated: Mon, 26 Oct 2026