บทนำ
ใน PHP 7 Interface Throwable ทำหน้าที่เป็น base สำหรับออบเจกต์ใดๆ ที่สามารถเป็นพารามิเตอร์ของคำสั่ง throw รวมถึง Error และ Exception ทั้งคลาส Error และ Exception ซึ่ง predefined และ user-defined error/exception classes มาจากคลาสเหล่านี้ตามลำดับ implement Throwable interface เมธอด abstract ต่อไปนี้ถูกกำหนดใน Throwable interface
ไวยากรณ์
Throwable { abstract public getMessage ( void ) : string abstract public getCode ( void ) : int abstract public getFile ( void ) : string abstract public getLine ( void ) : int abstract public getTrace ( void ) : array abstract public getTraceAsString ( void ) : string abstract public getPrevious ( void ) : Throwable abstract public __toString ( void ) : string }เมธอด
getMessage ( void ) - string - คืนค่าข้อความที่เกี่ยวข้องกับออบเจกต์ที่โยน
getCode ( void ) - int - คืนค่ารหัสข้อผิดพลาดที่เกี่ยวข้องกับออบเจกต์ที่โยน
getFile ( void ) - string - รับชื่อไฟล์ที่ออบเจกต์ที่โยนถูกสร้าง
getLine ( void ) - int - คืนค่าหมายเลขบรรทัดที่ออบเจกต์ที่โยนถูกสร้าง instance
getTrace ( void ) - array - คืนค่า stack trace เป็น array
getTraceAsString ( void ) - string - คืนค่า stack trace เป็น string
getPrevious ( void ) - Throwable - คืนค่า Throwable ก่อนหน้า (ที่ส่งเป็นพารามิเตอร์ที่ 3 ให้ Exception::__construct())
__toString ( void ) - string - รับ string representation ของออบเจกต์ที่โยน