การอ้างอิงข้อยกเว้น PHP
วัตถุข้อยกเว้น PHP
ข้อยกเว้นถูกใช้โดยฟังก์ชันและวิธีการส่งข้อมูลเกี่ยวกับข้อผิดพลาดและพฤติกรรมที่ไม่คาดคิด
วัตถุข้อยกเว้นไม่มีคุณสมบัติสาธารณะ แต่มีคุณสมบัติส่วนตัวและได้รับการป้องกันซึ่งสามารถเขียนหรืออ่านจากการใช้ตัวสร้างและเมธอด
วัตถุข้อยกเว้นมีวิธีการดังต่อไปนี้:
Method | Description |
---|---|
Exception() | The contructor of the Exception object |
getCode() | Returns the exception code |
getFile() | Returns the full path of the file in which the exception was thrown |
getMessage() | Returns a string describing why the exception was thrown |
getLine() | Returns the line number of the line of code which threw the exception |
getPrevious() | If this exception was triggered by another one, this method returns the previous exception. If not, then it returns null |
getTrace() | Returns an array with information about all of the functions that were running at the time the exception was thrown |
getTraceAsString() | Returns the same information as getTrace(), but in a string |