Learn about Dynamic Web technology some methods of error handling in PHP _php tutorial

Source: Internet
Author: User
have been playing PHP for some time, the basic is from 0 start, often appear a lot of problems, slowly can be proficient in querying documents, and, experience is not a lot.

Look at here first. :

Error_reporting (1048);//1,2,4,7,...,1048
Ob_start ();
Session_Start ();
Date_default_timezone_set (Asia/shanghai);

PHP's recursive calls consume a lot of memory.
Generally, do not use define too much.
In the construction and property of the class, 5 has done a lot of work, to overcome the bug is not said, __ series of functions are some aspects, but also support StaticOf

According to the program I have written now, rarely use the framework page, I feel that the speed in PHP is not a problem.

Note the order in which classes are called, especially those that have been extends, to release memory accurately.

@mysql_fetch_array ($result, MYSQL_ASSOC); This note uses chaos, Mysql_assoc,mysql_num and Mysql_both are an enum. The default is Mysql_both.

The MySQL statement, if executed in, no longer supports limit. So ... Very troublesome.

Support Distinct,group, program loop execution, Md.

if (GET_MAGIC_QUOTES_GPC ()) {
$_get= STRIPSLASHES_GPC ($_get);
$_post= STRIPSLASHES_GPC ($_post);
$_cookie= STRIPSLASHES_GPC ($_cookie);
}
Set_magic_quotes_runtime (0); #magic_quotes_runtime
function STRIPSLASHES_GPC ($array) {
while (list ($key, $value) = each ($array)) {
if (is_string ($value)) {
$array [$key] = Addslashes (stripslashes ($value));
} else if (Is_array ($value)) {
$array [$key] = STRIPSLASHES_GPC ($value);
}
}
return $array;
}
/**
* Errors that occur in the handler
* @Date: 2006-10-9-10:51
* @param (type) (parameter name) (description)
*/
function Error_Handler ($errno, $errstr, $errorfile, $errline, $errtext) {
Echo (the system has an error:. $errstr);
Echo (at. $errorfile. $errline. Line.);
if ($errno ==e_user_error) {
Echo (fatal error, program aborted);
}

}

At the time of Use: Set_error_handler (Error_Handler);
Trigger_error (call trigger_error,e_user_error);


This is obtained using a function, and of course your error reporting level should be high:
Error_reporting (1048);


To be more oo, first look at a self-writing function that describes the class:
$classname =exception;
/**
* (function description)
* @Date:
* @param (type) (parameter name) (description)
*/
function Classdetail ($classname) {
if (!class_exists ($classname)) {
Echo ($classname. Class does not exist);
}else{
Print_r ("description class below". $classname);
Print_r ("All Methods
");
Print_r (Get_class_methods ($classname));
Print_r ("
");
Print_r (" All the properties
");
Print_r (Get_class_vars ($classname));
Print_r ("
");
}
}
Classdetail ($classname);


All get methods found for the exception class are:

[0] = __construct
[1] = GetMessage
[2] = GetCode
[3] = GetFile
[4] = GetLine
[5] = Gettrace
[6] = gettraceasstring
[7] = __tostring

Slowly optimize the personality point, also can.



OK, look at the comparison of OO processing methods:
Class Errorhandlers extends exception{
Private $_context = null;
function __construct ($level, $string, $file, $line, $context =null) {
Parent::__construct ($string, $level);
$this->file = $file;
$this->line = $line;
$this->_level = $level;
$this->_context = $context;
}
function __destruct () {
Parent::__destruct ();
}
function Message () {
$errors = Array (
E_error = ERROR,
e_warning = WARNING,
E_parse = parsing error,
E_notice = NOTICE,
E_core_error = CORE ERROR,
e_core_warning = CORE WARNING,
E_compile_error = COMPILE ERROR,
e_compile_warning = COMPILE WARNING,

http://www.bkjia.com/PHPjc/509198.html www.bkjia.com true http://www.bkjia.com/PHPjc/509198.html techarticle have been playing PHP for some time, the basic is the beginning of from0, often appear a lot of problems, slowly can be proficient in querying documents, and, experience is not a lot. First Lookhere. : ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.