10个非常经典的php代码片段.doc
还剩
8页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,喜欢就下载吧,价低环保!
内容要点:
27. set_error_handler('nettuts_error_handler'); 28. 29. // Trigger an error... (var doesn't exist) 30. echo $somevarthatdoesnotexist; 75. } 76. fclose($conn); 77. } 78. else { die('Error: Could not connect to ' . $nic_server . '!'); } 79. 80. return $output; 81. } 10. 不显示 PHP 错误而发送电子邮件取代之如果你不想在页面中显示 PHP 错误,也可以通过 email 来获取错误信息。下面的代码可以帮助你实现。Php 代码 1. An error ($number) occurred on line 7. $line and in the file: $file. 8. $message "; 9. 10. $email .= "" . print_r($vars, 1) . ""; 11. 12. $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 13. 14. // Email the error to someone... 15. error_log($email, 1, [email protected]', $headers); 16. 17. // Make sure that you decide how to respond to errors (on the user's side) 18. // Either echo an error message, or kill the entire project. Up to you... 19. // The code below ensures that we only "die" if the error was more than 20. // just a NOTICE. 21. if ( ($number !== E_NOTICE) && ($number < 2048) ) { 22. die("There was an error. Please try again later."); 23. } 24. } 25. 26. // We should use our custom function to handle errors. 31. "int" => "whois.iana.org", 32. "ac" => "whois.nic.ac", 33. "ae" => "whois.uaenic.ae", 34. "at" => "whois.ripe.net", 35. "au" => "whois.aunic.net", 36. "be" => "whois.dns.be", 37. "bg" => "whois.ripe.net", 38. "br" => "whois.registro.br", 39. "bz" => "whois.belizenic.bz", 40.
发表评论
暂无评论,赶快抢占沙发吧。