One, the error of the procedure itself
This error is a relatively easy to handle errors, such as syntax errors or the compiler can not resolve, these errors at compile time, will not compile, and then according to the wrong hint, to find the specific error code. However, when there is an error in the code that is executed with eval (), it is not found during compilation, it can only wait until the code is executed, and the compiler generates an error, as we execute the following code, we will have an error during execution:
[PHP] view plain copy <?php echo "This'll be the echo to Putty"; Eval ("PHP error when parser"); ?> This error differs from other code errors, the echo is output before it is located. Other code errors do not have any output, because the compilation is not going to work.
Two, undefined symbol
When PHP executes, it may encounter many variables, functions, etc. it does not know the name, because PHP in the compile time, and did not fully understand all the symbol name, function name and so on.
If just undefined constants or variables, this is just a notification in the form of notifications. However, if you encounter an undefined function or class, the program will terminate the operation. When you can't find a class, if the user defines a function called __autoload, it will be invoked when PHP encounters an undefined class, and if you can return the class through this function, the newly loaded class will be used without any errors.
Third, universal error
3.1 Differences in operating systems
Some PHP functions that are available only on a particular platform.
Some PHP functions that are not available on a particular platform.
Some PHP functions that have subtle differences under different platforms.
The character that distinguishes the path component in the file name.
External programs or services are not available on all platforms.
3.2 PHP Configuration differences
For example, the configuration option MAGIC_QUOTES_GPC, if this option is turned on, PHP will increase the slash to all external data. At this point, the user's input will be problematic if the program is ported to another server that does not have this option open. The way to handle similar differences is to check the PHP code and see if the option is enabled through the Ini_get () function, and then make a uniform adjustment.
Register_globals: This setting determines whether PHP introduces Get,post,cookie, environment variables, or server variables as global variables. Generally avoid use.
Allow_url_fopen: If this option is set to False, the function of the URL file operation is turned off.
3.3 Sapi Difference
Four, run the error
such as the hard disk data or network operations and database calls, due to the factors outside the PHP itself caused by errors.
Five, PHP error
The error mechanism in PHP is used by all PHP built-in functions, and usually this simple mechanism prints out an error message, including some basic information about the error.
The error levels are divided into:
E_error: Critical error.
E_warning: The most common type of error.
E_parse: Parse error occurs at compile time.
E_strict: This error level is the only one not included in the E_all constant, in order to make the migration of PHP4 to PHP5 easier.
E_notice: Indicates that the running code may be manipulating something unknown.
E_core_error: caused by extended start failure.
E_compile_warning: A warning that occurs when compiling, telling the user some syntax information that is deprecated.
E_compile_error: Compilation error.
E_user_error
E_user_warning
You can use the error_reporting (Integer) function to set which errors are reported. If all errors are expressed as e_all, all errors other than notices can be expressed as E_all & ~e_notice.
Display_errors (Boolean): This setting controls whether the error is displayed as part of the PHP output.
Log_errors (Boolean), this setting controls whether the error is logged. The address of the log is determined by the Error_log (String) setting. By default, errors are logged to the Web server's error log.
Html_errors (Boolean): Sets whether control is in HTML format in error messages.
Vi. Defining the error handler
You can call Set_error_handler (error_handle_function,error_types) to specify the error processor. Such as
function Customerror ($errno, $errstr, $errfile, $errline)
{
echo "<b>custom error:</b> [$errno] $errstr <br/>";
}
Set_error_handler ("Customerror"); Default for all errors, is e_all.