In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the problems solved by PHP programmers". In daily operation, I believe that many people have doubts about the problems solved by PHP programmers. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what problems PHP programmers solve?" Next, please follow the editor to study!
Lv0 View PHP error message
The program did not achieve the desired results, to prove that the code is wrong, look at the error message of PHP is the first step. If you ignore the error message directly, it shows that this person is not suitable for a professional programmer position. In some cases, the error display is turned off in the php.ini configuration, the php.ini open error message needs to be modified, or the error message is exported to the log file. In this case, you can view the error message directly by tailf php_error.log.
After getting the error message, directly locate the program code problem, or search to Google/ Baidu, you can solve the problem.
Note: the way to turn on the error display is
Set display_errors / display_startup_errors to On in php.ini
Set error_reporting to E_ALL in php.ini
Set error_reporting (E_ALL) in PHP code
There are multiple versions of Lv1 php or php-cli loading different configurations from php-fpm
There are multiple versions of php, know which PHP to see through which php, or add an absolute path to make the php version. Indicates that this PHPer has passed the 50% test at this level.
Another situation is that the execution of php-cli is different from that of php-fpm, for example, the execution is right in web browser and wrong in cli. This may be due to the different php.ini loaded by the two environments. Under cli, use php-I | grep php.ini to get which php.ini is loaded. Under fpm, the absolute path of php.ini can be obtained by phpinfo () function.
Lv2 var_dump/die print variable value information single step debugging
This is the usual means of program debugging, and it is also the simplest, rough and effective way to solve the problem. The more advanced approach is to use PHP's Trace class / log class, and the fancy one can use phpstorm+xdebug to Debug in the IDE tool.
The Trace tool can also analyze the time consuming of scripts and optimize the performance of PHP code.
All three tests have passed, indicating that this programmer already has the problem-solving ability that a professional PHP programmer should have. As long as PHP programmers pass this level, they will be able to cope with most situations and have no pressure in small and medium-sized websites.
Lv3 uses strace tools to track program execution
Strace can be used to view the execution of system calls, using strace php test.php, or the strace-p process ID. Strace can help you see the essence through the phenomenon and master the process of program execution. This method is most commonly used in large websites and large companies. If you don't master strace, you can only say sorry here. We don't accept PHPer that can't strace.
In fact, strace is also a test of the foundation of programmers. If you do not know how to operate the operating system and do not understand the bottom, you will certainly not be able to use strace. Of course, strace can't solve the endless loop in the PHP source code. For example, if you find a php-fpm process CPU100%, strace may not be able to solve it. Because strace depends on system calls, it is generally operated like IO. Since it is IO-intensive, CPU must not be 100%.
Lv4 uses tcpdump tools to analyze the process of network communication
Tcpdump can catch the data communication process of the network card, and even the data content. Using tcpdump, you can see what the network communication process looks like, when the TCP SYN3 handshake is initiated, when the FIN packet is sent, and when the RST packet is sent. This is a basic skill. If you do not understand tcpdump, you will prove that you do not have the ability to solve network problems.
Time consuming and success rate of Lv5 statistics function calls
Use xhporf/xdebug to export the calling procedure for the PHP request, and then analyze the procedure and time-consuming of each function call. Be able to analyze the performance bottleneck of PHP programs and find out the points that can be optimized.
Another call to a network service, such as mysql query, curl, and other API calls, can get whether the call was successful and how long it took by recording whether the microtime at the start and end is false or not. If you can summarize the data and sort out the success rate, failure rate and average delay of the call, it proves that this programmer is sensitive to the quality of the interface and has experience in large-scale website projects.
Lv6 gdb usage
Gdb is a sharp tool for CAccord Clipper + debugger, and programmers with certain skills are needed to skillfully use gdb. The strace mentioned above cannot track the php program CPU100%, while gdb can. In addition, gdb can also solve the problem of php program core dump.
Through the gdb-p process ID, combined with php-src 's .gdbinit zbacktrace and other tools, you can easily track the execution of PHP programs. Like the CPU100% above, there is often an endless loop in the PHP program. Gdb can check it many times and roughly get the location of the dead loop. There are very few PHP programmers with gdb problem-solving skills. If you can use gdb to solve PHP problems, the PHPer can pass the interview and get a high technical rating.
Lv7 to view the PHP kernel and extended source code
If you are familiar with the PHP kernel and the source code of the extension, you can also have the ability to solve the most complex memory errors in PHP programs. Such PHP programmers are rare. With gdb tools and familiarity with PHP source code, you can view opcode information, execute_data memory, global variable status, and so on.
At this point, the study of "what are the problems solved by PHP programmers" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.