ตัว สร้างข้อยกเว้น PHP
ตัวอย่าง
<?php
...
throw new Exception("Division by zero", 1);
...
?>
ความหมายและการใช้งาน
คอน สตException()
รัคเตอร์ใช้เพื่อสร้างอ็อบเจ็กต์ Exception และตั้งค่าคุณสมบัติบางอย่าง
ไวยากรณ์
new Exception(message, code, previous)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
message | Optional. A string describing why the exception was thrown |
code | Optional. An integer that can be used used to easily distinguish this exception from others of the same type |
previous | Optional. If this exception was thrown in a catch block of another exception, it is recommended to pass that exception into this parameter |
หน้าที่เกี่ยวข้อง
อ่านเพิ่มเติมเกี่ยวกับข้อยกเว้นในบทข้อยกเว้น PHPของ เรา
❮ การอ้างอิงข้อยกเว้น PHP