For tips on PHP debugging, check it out!

藏色散人
Release: 2023-04-10 16:48:02
forward
3141 people have browsed it

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)
Copy after login

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);
Copy after login

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

$ tailf /tmp/my.log
Copy after login

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!

Related labels:
php
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!