PHP2 debugging method _ PHP Tutorial

Source: Internet
Author: User
PHP2 debugging method. 1. use echo, print, print_r, var_export, or var_dump to directly output data to the browser. in this case, there is no interruption or jump in the middle of the page, usually followed by exit. 1. directly output the project to the browser using echo, print, print_r, var_export, or var_dump.
In this case, there is no interruption or jump in the middle of the page, usually followed by exit.
After the project is officially launched, will the debugging code be removed or added with comments? if not removed, too much junk code will appear, and the performance may be a small problem.
2. write the value of the variable to be output to the file.
In this case, PHP network functions are generally used to implement Socket connections, such as any connections established through fopen (), fsockopen (), and pfsockopen.
This debugging method is most suitable for requests not from browsers, but from client software (Appendix L. supported protocol/Encapsulation Protocol list), especially in the development and debugging stage, if there is no log, the program can hardly be debugged (because the program is called by the client, there is no interface, in this case, echo debugging is not feasible)

For example, ucenter integrates third-party PHP applications, and ucenter establishes connections to multiple applications. we only need to use the third-party PHP application uc. in php, the $ get variable is written to the file, and then the file is read to know the action, id, and other data that ucenter sends to each application.
Php writes arrays to files
$ File = "./data/log.txt ";
$ Array = array ("count" => "3000", "num" => "300 ″);
File_put_contents ($ file, serialize ($ array); // write cache
?>

Author "danbaise"

In this case, there is no interruption or jump in the middle of the page, usually followed by exit. After the project is officially launched...

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.