1. Use echo, print, print_r, var_export or var_dump to directly output to the browser
In this case, there is no interruption or jump in the middle of the page, and is usually followed by exit.
After the project is officially launched, should these debugging codes be removed or added with comments? If not removed, it will appear that there are too many junk codes and there may be minor performance issues.
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 links, such as any connections established through fopen(), fsockopen() and pfsockopen().
The most applicable place for this debugging method is that the request does not come from the browser, but from the client software (Appendix L. List of supported protocols/encapsulated protocols), especially during the development and debugging phase. If there are no logs, the program will be almost Unable to debug (because the program is called by the client and has no interface, so debugging using echo is not possible at this time)
For example, ucenter integrates third-party PHP applications, and ucenter establishes connections to multiple applications. We only need to write the file with the $get variable in the third-party PHP application uc.php, and then read the file, and then we can know the data sent by ucenter to each application. action, id and other data.
php writes array to file
$file=”./data/log.txt”;
$array = array(“count” => “3000″, “num” => “300″);
file_put_contents($file,serialize($array));//Write cache
?>
Author "danbaise"