मैं लीप ले रहा हूं: मेरी PHP स्क्रिप्ट सभी शानदार ढंग से विफल हो जाएंगी!set_error_handler काम नहीं कर रहा है मैं इसे कैसे काम करना चाहता हूं
कम से कम, कि मैं क्या आशा करती हूं कि के लिए ...
मैं रैप करने के लिए (व्यावहारिक रूप से) कोशिश ... पकड़ बयान में हर एक लाइन नहीं करना चाहती है, तो मुझे लगता है कि मेरी सबसे अच्छी शर्त करने के लिए है मेरी फाइलों की शुरुआत के लिए कस्टम त्रुटि हैंडलर बनाएं।
मैं इसे बाहर का परीक्षण कर रहा हूँ एक अभ्यास पृष्ठ पर:
function customError($level,$message,$file,$line,$context) {
echo "Sorry, an error has occured on line $line.<br />";
echo "The function that caused the error says $message.<br />";
die();
}
set_error_handler("customError");
echo($imAFakeVariable);
यह काम करता है ठीक, लौटने:
Sorry, an error has occured on line 17. The function that caused the error says Undefined variable: imAFakeVariable.
हालांकि, इस स्थापना अपरिभाषित कार्यों के लिए काम नहीं करता।
function customError($level,$message,$file,$line,$context) {
echo "Sorry, an error has occured on line $line.<br />";
echo "The function that caused the error says $message.<br />";
die();
}
set_error_handler("customError");
imAFakeFunction();
यह रिटर्न:
Fatal error: Call to undefined function: imafakefunction() in /Library/WebServer/Documents/experimental/errorhandle.php on line 17
क्यों अपने कस्टम त्रुटि हैंडलर अपरिभाषित कार्यों को पकड़ने नहीं है? क्या ऐसी कोई अन्य समस्याएं हैं जिनसे इसका कारण होगा?