|
Vordefinierte ExceptionsInhaltsverzeichnis
Siehe auch das Kapitel SPL-Exceptions. ExceptionEinführungException ist die Basisklasse für alle Exceptions. KlassenbeschreibungException
class Exception
{
/* Eigenschaften */
protected
string
$message
;
protected
int
$code
;
protected
string
$file
;
protected
int
$line
;
/* Methoden */
public __construct
([ string
$message = ""
[, int $code = 0
[, Exception $previous = NULL
]]] )
final public string getMessage
( void
)
final public Exception getPrevious
( void
)
final public mixed getCode
( void
)
final public string getFile
( void
)
final public int getLine
( void
)
final public array getTrace
( void
)
final public string getTraceAsString
( void
)
public string __toString
( void
)
final private void __clone
( void
)
}Eigenschaften
ErrorExceptionEinführungEine Error Exception. KlassenbeschreibungErrorException
class ErrorException
extends
Exception
{
/* Eigenschaften */
protected
int
$severity
;
/* Geerbte Eigenschaften */
protected
string
$message
;
protected
int
$code
;
protected
string
$file
;
protected
int
$line
;
/* Methoden */
public __construct
([ string
$message = ""
[, int $code = 0
[, int $severity = 1
[, string $filename = __FILE__
[, int $lineno = __LINE__
[, Exception $previous = NULL
]]]]]] )
final public int getSeverity
( void
)
/* Geerbte Methoden */
final public string Exception::getMessage
( void
)
final public Exception Exception::getPrevious
( void
)
final public mixed Exception::getCode
( void
)
final public string Exception::getFile
( void
)
final public int Exception::getLine
( void
)
final public array Exception::getTrace
( void
)
final public string Exception::getTraceAsString
( void
)
public string Exception::__toString
( void
)
final private void Exception::__clone
( void
)
}Eigenschaften
Beispiele
Beispiel #1 Verwenden von set_error_handler zum Verändern von Fehlermeldungen innerhalb ErrorException.
<?phpDas oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
Fatal error: Uncaught exception 'ErrorException' with message 'strpos() expects at least 2 parameters, 0 given' in /home/bjori/tmp/ex.php:12
Stack trace:
#0 [internal function]: exception_error_handler(2, 'strpos() expect...', '/home/bjori/php...', 12, Array)
#1 /home/bjori/php/cleandocs/test.php(12): strpos()
#2 {main}
thrown in /home/bjori/tmp/ex.php on line 12
|