PHP 2 Debugging Methods _php Tutorial

Source: Internet
Author: User
1. Direct output to the browser with Echo, print, Print_r, Var_export, or Var_dump
This situation does not appear in the middle of the page break and jump, usually followed by exit.
After the project is officially launched, these debugging code is removed or annotated, if not removed, it will appear too much garbage code, performance may be a little bit of a problem.
2. Write the value of the variable you want to output to a file
This is typically done with a PHP network function to implement a socket link, such as any connection made through fopen (), Fsockopen (), and Pfsockopen ().
The most appropriate way to do this is if the request is not from the browser, but from the client software (Appendix L. List of supported protocols/wrappers), especially in the development debugging phase, if there is no log, the program is almost impossible to debug (because the program is called by the client, there is no interface, This is not the way to debug with Echo

For example, Ucenter integrates a third-party PHP application, Ucenter connects to multiple applications, and we just need to write the $get variable in a third-party PHP application uc.php and then read the file to know the Ucenter that Action,id sends to each app.
PHP writes an array to a file
$file = "./data/log.txt";
$array = Array ("Count" = "3000″", "num" = "300″");
File_put_contents ($file, serialize ($array));//write Cache
?>

Author "Danbaise"

http://www.bkjia.com/PHPjc/478643.html www.bkjia.com true http://www.bkjia.com/PHPjc/478643.html techarticle 1. Direct output to the browser with Echo, print, Print_r, Var_export, or var_dump This situation does not appear in the middle of the page interrupt and jumps, generally 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.