Home>Article>Backend Development> PhpStorm local breakpoint debugging method
When debugging PHP code, print_r or var_dump is often used to set breakpoints. However, when the project is more complex, this is very inefficient. Breakpoint debugging solves this problem very well. This article It mainly introduces the methods and steps of PhpStorm local breakpoint debugging. Interested friends can refer to
Foreword:
When debugging PHP code, print_r or var_dump is often used to set breakpoints. However, when the project is more complex, this is very inefficient. Breakpoint debugging solves this problem very well. You may not be comfortable with breakpoint debugging at first, but once you get used to it, the more you use it, the more comfortable you will become.
Note: The following is in the windows7 apache environment
1. Breakpoint debugging php environment setup
1. Detect local Whether Xdebug is installed in the php environment
Output phpinfo() locally; search for Xdebug; as shown below
[xdebug] ;zend_extension的值根据自己的本地环境填写 zend_extension = "D:/IdeMix442_jcp/php-5.5.27-Win32-VC11-x64/ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll" xdebug.idekey=phpstorm xdebug.remote_enable = On xdebug.remote_host=localhost ;xdebug.remote_port默认值为9000,这里需要跟phpstorm配置一致,下面有说明 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.auto_trace = On3. Then configure phpstorm, and ensure that the Debug port is not occupied by other applications. When the program cannot enter the breakpoint, you can consider whether it is occupied by other applications. Your local port 9000.
##2. Start your breakpoint debugging1. In your browser with the Xdebug extension installed, open a page of your local project. And turn on debug in the upper right corner of the browser, as shown below.
2. In your phpstorm editor, open the code you want to go through on the page in the browser, and operate as shown below.
3. Refresh the page you opened in the browser again, and then look at your phpstorm editor. The red circle at the breakpoint on the left changes to a check mark in the circle, which means you have entered the breakpoint. As shown below
3. Some simple operations for breakpoint debugging1. View The values of some variables before your breakpoint
Double-click the variable you want to view, and the value will appear when the mouse stays on it. Or right-click after selecting it and select Add to Watch (the English version is add to watch), as shown below
## 2. From where your breakpoint starts, you can press F7, and the program will go down step by step. If it encounters a function, it will jump to that function; press F8 to go down line by line in the current code page. It will not jump when it encounters a function. These two functions are the most practical and key functions of breakpoint debugging.
3. When you want to jump directly from a breakpoint to a breakpoint on another line, you can enter the breakpoint, click on the breakpoint where you want to breakpoint on another line, and then press Press F9 or click the green button in the lower border, as shown below.4. When you breakpoint in multiple places due to breakpoint debugging, and open multiple files, and want to see where you have breakpoints, you can press Ctrl Shift F8 to browse the breakpoints. Click
#5. There are many tips for breakpoint debugging. You can slowly discover and explore them while using them.
The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope that everyone will support Script House.
Basic skills for PHP MariaDB database operation
##PHP database operation class based on pdo
PHP implementation of mysql read-write separation related content
The above is the detailed content of PhpStorm local breakpoint debugging method. For more information, please follow other related articles on the PHP Chinese website!