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"