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...