Home > Article > Backend Development > PHP code error detection and verification
What kinds of error messages are there in php
1.notice: Note
2. warning: warning (recommended learning: PHP video tutorial)
3.error: error
What are the error checking methods in PHP?
1. Syntax check--in the php configuration file, turn on the error display options or add error_reporting(E_ALL) at the beginning of the code
2. Logic check--set break point, write the log before the breakpoint error_logs($message);exit();
3. HTTP debugging--use the packet capture tool or firebugs tool to track the entire process of code running
PHPCS is a tool for code detection and standardization
PHP code specifications have PSRs. In order to achieve automated inspection and repair of code specifications, PHPCS needs to be used.
Common commands
Check a single file: phpcs /path/to/code
Check the file in the directory: phpcs /path/to/code /
View installed standards: phpcs -i
Set the default check standard: phpcs --config-set default_standard /path/to/standard_file
View configuration: phpcs --config-show
Specify the report format: phpcs --report=summary /path/to/code; available report formats are full, xml, checkstyle, csv, json, emacs, source, summary, diff , svnblame, gitblame, hgblame, notifysend, the default is full
View help: phpcs -h
Automatic repair: phpcbf /path/to/code
Detailed instructions See official wiki
The above is the detailed content of PHP code error detection and verification. For more information, please follow other related articles on the PHP Chinese website!