thinkphp Debug Solution

Source: Internet
Author: User

Hink PHP provides a page debug scenario, Trace.

Using this debug scenario, you only need to use the following sentence in the configuration file:

' Show_page_trace ' =>true

The effect is as follows:

In the bottom right corner of each page, there will be a button that you can open:

There are a lot of page information in it.

Specifically, you can configure what information is available on your own, by:

1' Trace_page_tabs ' =Array(2' Base ' = ' basic ',3' File ' = ' files ',4' Think ' = ' process ',5' Error ' = ' wrong ',6' SQL ' = ' sql ',7' Debug ' = ' Commissioning ',8' User ' = ' users '9 )TenOr One' Trace_page_tabs ' =Array( A' Base ' = ' basic ', -' File ' = ' files ', -' Think ' = ' process ', the' Error|debug|sql ' = ' Debug ', -' User ' = ' users ' -)

As you can see, in the debug information above, the user is not shown in the actual page, that is the custom debugging information, using the method is: You can use the trace function in any program you call

1 Trace ($user, ' User information ', ' users '); 2 Trace ("Cheng Yu", "Handsome Man", "user");

By default, trace information is not saved, but you can use the following configuration item to save the trace information:

' Page_trace_save ' =>true

After the page trace information is saved, each page trace information is saved to the log directory of the project, and the naming format is:
Current date _trace.log

If you only want to save some trace information, you can use a configuration similar to the following:

' Page_trace_save ' = = Array (' base ', ' file ', ' SQL ');

The trace function has four parameters, which gives the source code for the trace function:

1 function Trace ($value= ' [think] ',$label= ',$level= ' DEBUG ',$record= false ) {2     return think\think::trace ($value,$label,$level ,$record); 3 }

Based on the trace scheme above, you can do a lot of power-off debugging. In addition, think PHP provides another efficient debugging scheme similar to PHP inside the var_dump and Print_r called the dump function, using this function can be used to print the variable at the bottom of the page.

You can do a lot of things based on the dump function, for example, you can print out all of the page's exception information:

1 Dump (E (' Error '));

The effect of the above code is:

In addition, there is a scenario called model debugging, similar to the exception that was thrown before the capture in Java, but slightly different.

thinkphp Debug Solution

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.