You are on page 1of 5

Downloads

Documentation
Get Involved
Help

Search

Getting Started
Introduction
A simple tutorial
Language Reference
Basic syntax
Types
Variables
Constants
Expressions
Operators
Control Structures
Functions
Classes and Objects
Namespaces
Errors
Exceptions
Generators
References Explained
Predefined Variables
Predefined Exceptions
Predefined Interfaces and Classes
Context options and parameters
Supported Protocols and Wrappers

Security
Introduction
General considerations
Installed as CGI binary
Installed as an Apache module
Session Security
Filesystem Security
Database Security
Error Reporting
Using Register Globals
User Submitted Data
Magic Quotes
Hiding PHP
Keeping Current
Features
HTTP authentication with PHP
Cookies
Sessions
Dealing with XForms
Handling file uploads
Using remote files
Connection handling
Persistent Database Connections
Safe Mode
Command line usage
Garbage Collection
DTrace Dynamic Tracing

Function Reference
Affecting PHP's Behaviour
Audio Formats Manipulation
Authentication Services
Command Line Specific Extensions
Compression and Archive Extensions
Credit Card Processing
Cryptography Extensions
Database Extensions
Date and Time Related Extensions
File System Related Extensions
Human Language and Character Encoding Support
Image Processing and Generation
Mail Related Extensions
Mathematical Extensions
Non-Text MIME Output
Process Control Extensions
Other Basic Extensions
Other Services
Search Engine Extensions
Server Specific Extensions
Session Extensions
Text Processing
Variable and Type Related Extensions
Web Services
Windows Only Extensions
XML Manipulation
GUI Extensions

Keyboard Shortcuts
?
This help
j
Next menu item
k
Previous menu item
gp
Previous man page
gn
Next man page
G
Scroll to bottom
gg
Scroll to top
gh
Goto homepage
gs
Goto search
(current page)
/
Focus search box

Exception::__construct
Excepciones predefinidas

Manual de PHP
Referencia del lenguaje
Excepciones predefinidas

Change language: Spanish

Edit Report a Bug

Exception
(PHP 5 >= 5.1.0, PHP 7)

Introduccin
Exception es la clase base para todas las excepciones en PHP 5, y la clase base para
todas las excepciones de usuario en PHP 7.

En PHP 7, Exception implementa la interfaz Throwable.

Sinopsis de la Clase
Exception {
/* Propiedades */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Mtodos */
public __construct ([ string $message = "" [, int $code = 0 [, Throwable $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 )
}

Propiedades
message

El mensaje de la excepcin
code

El cdigo de la excepcin

file

El nombre del fichero donde se origin la excepcin

line

La lnea donde se origin la excepcin

Tabla de contenidos
Exception::__construct Constructor de la excepcin
Exception::getMessage Obtiene el mensaje de Excepcin
Exception::getPrevious Devuelve la excepcin anterior
Exception::getCode Obtiene el cdigo de una excepcin
Exception::getFile Obtiene el fichero donde ocurri la excepcin
Exception::getLine Obtiene la lnea en donde ocurri la excepcin
Exception::getTrace Obtiene la traza de la pila
Exception::getTraceAsString Obtiene la traza de la pila como una cadena de
caracteres
Exception::__toString Representacin de la excepcin en formato cadena
Exception::__clone Clona la excepcin

add a note

User Contributed Notes 1 note

up
down
32
cHao
2 years ago
Note that an exception's properties are populated when the exception is *created*, not when it is
thrown. Throwing the exception does not seem to modify them.

Among other things, this means:

* The exception will blame the line that created it, not the line that threw it.

* Unlike in some other languages, rethrowing an exception doesn't muck up the trace.

* A thrown exception and an unthrown one look basically identical. On my machine, the only visible
difference is that a thrown exception has an `xdebug_message` property while an unthrown one
doesn't. Of course, if you don't have xdebug installed, you won't even get that.
add a note

Excepciones predefinidas
Exception
ErrorException
Error
ArithmeticError
AssertionError
DivisionByZeroError
ParseError
TypeError

Copyright 2001-2017 The PHP Group


My PHP.net
Contact
Other PHP.net sites
Mirror sites
Privacy policy

You might also like