पीएचपी सेट_अपवाद_हैंडलर () फ़ंक्शन
उदाहरण
उपयोगकर्ता द्वारा परिभाषित अपवाद हैंडलर फ़ंक्शन सेट करें:
<?php
// A user-defined exception handler function
function myException($exception)
{
echo "<b>Exception:</b> ", $exception->getMessage();
}
// Set user-defined exception handler function
set_exception_handler("myException");
// Throw exception
throw new Exception("Uncaught exception occurred!");
?>
परिभाषा और उपयोग
set_exception_handler() फ़ंक्शन उपयोगकर्ता द्वारा परिभाषित अपवाद हैंडलर फ़ंक्शन सेट करता है।
अपवाद हैंडलर को कॉल करने के बाद स्क्रिप्ट निष्पादित करना बंद कर देगी।
वाक्य - विन्यास
set_exception_handler(exceptionhandler);
पैरामीटर मान
Parameter | Description |
---|---|
exceptionhandler | Required. Specifies the name of the function to be run when an uncaught exception occurs. NULL can be passed instead, to reset this handler to its default state |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | एक स्ट्रिंग जिसमें पहले से परिभाषित अपवाद हैंडलर, या त्रुटि पर NULL या यदि कोई पिछला हैंडलर परिभाषित नहीं किया गया था |
---|---|
पीएचपी संस्करण: | 5.0+ |
पीएचपी चेंजलॉग: | पहले, यदि NULL पास किया गया था, तो यह फ़ंक्शन TRUE लौटाता है। यह PHP 5.5 के बाद से पिछला हैंडलर लौटाता है |
पीएचपी त्रुटि संदर्भ