Home  >  Article  >  Backend Development  >  For tips on PHP debugging, check it out!

For tips on PHP debugging, check it out!

藏色散人
藏色散人forward
2021-09-13 17:33:053172browse

For tips on PHP debugging, check it out!

PHP debugging tips

In the development machine environment, you can only use VIM and Emacs (I use Emacs) , there is no comparative tool for debugging PHP. Here is a function I commonly use:

file_put_contents('/tmp/my.log', print_r(array(date('Y-m-d H:i:s'), __LINE__, __METHOD__, ), TRUE)

This function can output a log to the /tmp/my.log file, including the date of function execution. , which line is executed and which method is executed. After __METHOD__, we can add the variable we want to print, such as $a, and then it is like the following:

file_put_contents('/tmp/my.log', print_r(array(date('Y-m-d H:i:s'), __LINE__, __METHOD__, $a), TRUE), FILE_APPEND | LOCK_EX);

Then we re-run the code and open a new window to monitor the log changes:

$ tailf /tmp/my.log

So that we can print out the $a variable.

Recommended learning: "PHP Video Tutorial"


The above is the detailed content of For tips on PHP debugging, check it out!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete