لمحترفي الويبPHP - معمو — الصفحة ٢٣٢

الفصل الثامن 232 البرنامج النصي trigger_error.php (تابع) 22. 23. error_log("Error ($number) on line $line in file $file. The error was \"" . trim($string) . "\"\n", 3, "error_log.txt"); } 24. break; 25. } 26. } 27. 28. 29. 30. 31. function failure () { ?> <h3>Sorry,</h3> <p>A problem has occured. The site administators have been notified and the problem should be resolved shortly. <p>Please try again later. <? 32. 33. } 34. 35. 36. 37. 38. } 39. 40. 41. 42. 43. ?> set_error_handler("error_handler"); if(!mysql_connect()) { $mysqlerr = mysql_error(); trigger_error("DATABASE CONNECT ERROR", E_USER_NOTICE); $username = "bob"; trigger_error("INVALID_LOGIN",E_USER_NOTICE); $msg = "Something Went Wrong!"; trigger_error ($msg, E_USER_ERROR); شرح البرنامج النصي trigger_error.php سطراً سطراً السطر الشرح 2-26 تعریف تابع معالجة خطأ مخصص يدعى ( )error_handler ، وهو يأخذ الوسطاء number : القيمة العددية للخطأ. string رسالة الخطأ. file مسار واسم الملف الذي وقع فيه الخطأ. عليم line : السطر الذي وقع عنده الخطأ. إنشاء المتحول timestamp وإسناده إلى الوقت والتاريخ الحاليين. 3
ص٢٣٢

نص مستخرج آليًا من الصورة، وقد يقع فيه خطأ.