PHP Debugging functions

Source: Internet
Author: User

<?php

#调试函数小结


1.debug_backtrace (): function generates a backtrace.

The function returns an associative array. Here are the elements that might be returned

Functions: Returns the current function name

Line: Current number of rows

File: The current file name

Class: The current category name

Object: Current Object

Type: The current invocation type, possibly called:

return->, Call of method

Return::, static method call

Return Nothing, Function call

Args: Array, if the function parameter is listed in the function. If the referenced file name is listed in the files being applied

Echo '

function Myfun ($arg) {

Print_r (Debug_backtrace ());

}

Myfun (' Hello ');


2.debug_print_backtrace (): function Output BackTrace

Echo '

function Myfun1 ($arg) {

Print_r (Debug_print_backtrace ());

}

Myfun1 (' Hello ');


3.error_get_last (): function gets the last error that occurred

The function returns the last error as an array, with 4 keys and values in the array, respectively:

Type: Error types

Message: Error message

File: The files where the error occurred

Line: The row where the error occurred

Echo '

/*error_reporting (0);

Echo $test;

Print_r (Error_get_last ()); * *


The 4.error_log (error,type,destination,headers) function returns an error that is sent to the server error record, file, or remote destination.

Returns true if successful, otherwise false

Error: Must be. The error message to log

Type: optional, respectively:

0-default. Depending on the error_log configuration in the php.ini file, the error is sent to the server log system or file

1-The error is sent to the address in the destination parameter. Only this type uses headers

2-send error via PHP debugging connection. option is only available in PhP3

3-Error sent to file destination string

Destination: Optional. Specifies where to send the error message. The value of the parameter depends on the value of the ' type ' parameter

Headers: optional, only when type 1 is used

Echo '


5.error_reporting (report_level): Set PHP error bounds and return to current level

Report_level, selectable values

1 or E_error: fatal error encountered during script run

2 or e_warning: Non-fatal run error

4 or E_parse: Compile-time parse error

8 or E_notice: Runtime notification, script discovery of a possible or error that occurs when a script is running normally

16 or e_core_error:php kernel-level error

32 or e_core_warning:php kernel-level warnings

64 or E_compile_error: Indicates compilation error

128 or E_compile_warning: Non-fatal compilation error

Any number of the above options can be connected (with OR or |) using "or" to report all required levels of error

Echo '

disabling error Reporting

error_reporting (0);

Report Run-time errors

Error_reporting (e_error| E_warning| E_parse);

Report All Errors

Error_reporting (E_all);

?>




This article is from "Tiger Brother's Blog" blog, please be sure to keep this source http://7613577.blog.51cto.com/7603577/1531698

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.