Table of Contents
About PHP programmers’ problem-solving abilities
Home Backend Development PHP Tutorial About the problem-solving ability of PHP programmers_PHP Tutorial

About the problem-solving ability of PHP programmers_PHP Tutorial

Jul 12, 2016 am 09:06 AM
php programmer ability question

About PHP programmers’ problem-solving abilities

This topic has been talked about for a long time. Among the abilities that must be assessed in interviews, I personally think that problem-solving ability ranks first, and has a higher priority than learning ability. The ability to solve problems can not only show the programmer's thinking ability, adaptability, exploration ability, etc., but also his experience. If you have poor problem-solving skills, you will not be able to pass the interview.

Here is an example, if I execute a PHP script, such as php test.php, it is expected to return a string. But no information is output after execution. How can we know where the program is wrong? The problem-solving ability can be divided into 8 levels here. The higher the level, the stronger the ability.

Lv0 View PHP error message

The program did not achieve the expected results, which proves that the code is wrong. Looking at the PHP error message is the first step. If you ignore the error message, it indicates 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, and you need to modify php.ini to open the error message, or the error message is exported to a log file. In this case, you can directly tailf php_error.log to see the error message.

After getting the error message, directly locate the program code problem, or search on Google/Baidu to solve the problem.

Note: The method to turn on the error display is

  • Set display_errors / display_startup_errors in php.ini to On

  • php.ini error_reporting is set to E_ALL

  • Set error_reporting(E_ALL) in PHP code

Lv1 There are multiple versions of php or php-cli and php-fpm load different configurations

There are multiple versions of php, know which PHP it is through which php, or add an absolute path to specify the php version. Indicates that this PHPer has passed 50% of the tests at this level.

Another situation is that the execution results obtained by php-cli and php-fpm are different. For example, the execution in the web browser is correct, but the execution in cli is wrong. At this time, it may be caused by the php.ini loaded in the two environments being different. Under cli, use php -i |grep php.ini to get which php.ini is loaded. The absolute path of php.ini can be obtained through the phpinfo() function under fpm.

Lv2 var_dump/die print variable value information single-step debugging

This is a commonly used method for program debugging, and it is also the simplest, crudest and most effective way to solve problems. A more advanced method is to use PHP's Trace class/log class. For a more fancy method, you can use phpstorm xdebug to debug in the IDE tool.

The Trace tool can also analyze the time consumption of scripts and optimize the performance of PHP programs.

All three tests have been passed, indicating that this programmer has the problem-solving abilities that a professional PHP programmer should have. As long as PHP programmers have passed this level, they will be able to cope with most situations and have no pressure on small and medium-sized websites.

Lv3 Use strace tool to track program execution

strace can be used to view the execution of system calls, use strace php test.php, or strace -p process ID. strace can help you see the essence through the phenomenon and grasp the process of program execution. This method is most commonly used in large websites and large companies. If you don't know strace, all I can say here is sorry, we don't accept PHPer who doesn't know strace.

strace is actually a test of the programmer's basics. If you don't know how to operate the operating system and don't understand the underlying layer at all, you will definitely not be able to use strace. Of course, strace cannot solve the infinite loop in PHP code. For example, if you find that the CPU of a php-fpm process is 100%, strace may not be able to solve it. Because strace looks at system calls, which are generally IO operations. Since it is IO intensive, the CPU cannot be 100%.

Lv4 uses the tcpdump tool to analyze the network communication process

tcpdump can capture the data communication process of the network card, and even the data content can be captured. You can use tcpdump to see what the network communication process looks like, when the TCP SYN 3-way handshake is initiated, when the FIN packet is sent, and when the RST packet is sent. This is a basic skill. If you don’t understand tcpdump, it proves that you do not have the ability to solve network problems.

Lv5 statistical function call time consumption and success rate

Use xhporf/xdebug to export the calling process of PHP requests, and then analyze the process and time consumption of each function call. Able to analyze performance bottlenecks of PHP programs and find points that can be optimized.

Another call to the network service , such as mysql query, curl, other API calls, etc., started by recording And at the end of microtime, if false is returned, you can get whether the call was successful and how much time it took. If the data can be summarized and the success rate, failure rate, and average delay of calls can be sorted out, it proves that this programmer is sensitive to interface quality and has experience in large-scale website projects.

Lv6 gdb use

gdb is a powerful tool for debugging C/C programs. Programmers need to have certain C/C skills to be able to use gdb proficiently. The strace mentioned above cannot track php program CPU100%, but gdb can track it. In addition, gdb can also solve the problem of core dump of php program. By gdb -p process ID, combined with php-src's .gdbinit zbacktrace and other tools, you can easily

track the execution of the PHP program. Like the CPU 100% above, it is often an infinite loop that occurs in the PHP program. If you check it multiple times with gdb, you can roughly get the location of the infinite loop. There are very few PHP programmers with the ability to solve problems with gdb. If you can use gdb to solve PHP problems, this PHPer can pass the interview 100% and get a higher technical rating.

Lv7 View PHP kernel and extension source code

If you are familiar with the PHP kernel and extended

source code, you will be able to solve the most complex memory errors in PHP programs. Such PHP programmers are rare. With the gdb tool and familiarity with PHP source code, you can view opcode information, execute_data memory, the status of global variables, etc.



http://www.bkjia.com/PHPjc/1064893.html

truehttp: //www.bkjia.com/PHPjc/1064893.htmlTechArticleThe topic of PHP programmers’ ability to solve problems has been talked about for a long time. Among the abilities that must be assessed in interviews, Personally, I think problem-solving ability comes first, taking precedence over learning ability...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
Clustering effect evaluation problem in clustering algorithm Clustering effect evaluation problem in clustering algorithm Oct 10, 2023 pm 01:12 PM

The clustering effect evaluation problem in the clustering algorithm requires specific code examples. Clustering is an unsupervised learning method that groups similar samples into one category by clustering data. In clustering algorithms, how to evaluate the effect of clustering is an important issue. This article will introduce several commonly used clustering effect evaluation indicators and give corresponding code examples. 1. Clustering effect evaluation index Silhouette Coefficient Silhouette coefficient evaluates the clustering effect by calculating the closeness of the sample and the degree of separation from other clusters.

Teach you how to diagnose common iPhone problems Teach you how to diagnose common iPhone problems Dec 03, 2023 am 08:15 AM

Known for its powerful performance and versatile features, the iPhone is not immune to the occasional hiccup or technical difficulty, a common trait among complex electronic devices. Experiencing iPhone problems can be frustrating, but usually no alarm is needed. In this comprehensive guide, we aim to demystify some of the most commonly encountered challenges associated with iPhone usage. Our step-by-step approach is designed to help you resolve these common issues, providing practical solutions and troubleshooting tips to get your equipment back in peak working order. Whether you're facing a glitch or a more complex problem, this article can help you resolve them effectively. General Troubleshooting Tips Before delving into specific troubleshooting steps, here are some helpful

How to solve the problem that jQuery cannot obtain the form element value How to solve the problem that jQuery cannot obtain the form element value Feb 19, 2024 pm 02:01 PM

To solve the problem that jQuery.val() cannot be used, specific code examples are required. For front-end developers, using jQuery is one of the common operations. Among them, using the .val() method to get or set the value of a form element is a very common operation. However, in some specific cases, the problem of not being able to use the .val() method may arise. This article will introduce some common situations and solutions, and provide specific code examples. Problem Description When using jQuery to develop front-end pages, sometimes you will encounter

Label acquisition problem in weakly supervised learning Label acquisition problem in weakly supervised learning Oct 08, 2023 am 09:18 AM

The label acquisition problem in weakly supervised learning requires specific code examples. Introduction: Weakly supervised learning is a machine learning method that uses weak labels for training. Different from traditional supervised learning, weakly supervised learning only needs to use fewer labels to train the model, rather than each sample needs to have an accurate label. However, in weakly supervised learning, how to accurately obtain useful information from weak labels is a key issue. This article will introduce the label acquisition problem in weakly supervised learning and give specific code examples. Introduction to the label acquisition problem in weakly supervised learning:

The problem of generalization ability of machine learning models The problem of generalization ability of machine learning models Oct 08, 2023 am 10:46 AM

The generalization ability of machine learning models requires specific code examples. With the development and application of machine learning becoming more and more widespread, people are paying more and more attention to the generalization ability of machine learning models. Generalization ability refers to the prediction ability of a machine learning model on unlabeled data, and can also be understood as the adaptability of the model in the real world. A good machine learning model should have high generalization ability and be able to make accurate predictions on new data. However, in practical applications, we often encounter models that perform well on the training set, but fail on the test set or real

Distortion control issues in image compression Distortion control issues in image compression Oct 08, 2023 pm 07:17 PM

Image compression is a commonly used technical means when storing and transmitting images. It can reduce the storage space of images and speed up the transmission of images. The goal of image compression is to reduce the size of the image file as much as possible while trying to maintain the visual quality of the image so that it can be accepted by the human eye. However, during the image compression process, a certain degree of distortion often occurs. This article discusses the issue of distortion control in image compression and provides some concrete code examples. JPEG compression algorithm and its distortion issues JPEG is a common image compression standard that uses

What are the questions in the Rulong 8 Wine Master exam? What are the questions in the Rulong 8 Wine Master exam? Feb 02, 2024 am 10:18 AM

What are the questions involved in the Yulong 8 Wine Master exam? What is the corresponding answer? How to pass the exam quickly? There are many questions that need to be answered in the Master of Wine Examination activities, and we can refer to the answers to solve them. These questions all involve knowledge of wine. If you need a reference, let’s take a look at the detailed analysis of the answers to the Yakuza 8 Wine Master exam questions! Detailed explanation of answers to questions in the Rulong 8 Wine Master exam 1. Questions about "wine". This is a distilled liquor produced by a distillery established by the royal family. It is brewed from the sugar of sugarcane grown in large quantities in Hawaii. What is the name of this wine? Answer: Rum 2. Question about "wine". The picture shows a drink made from dry ginseng and dry vermouth. It is characterized by the addition of olives and is known as "cockney"

How to solve the problem of the start menu that cannot be used after win11 installation How to solve the problem of the start menu that cannot be used after win11 installation Jan 06, 2024 pm 05:14 PM

Many users have tried to update the win11 system, but found that the start menu cannot be used after the update. This may be because there is a problem with the latest update. We can wait for Microsoft to fix or uninstall these updates to solve the problem. Let's take a look at it together. Solution. What to do if the start menu cannot be used after win11 is installed. Method 1: 1. First open the control panel in win11. 2. Then click the "Uninstall a program" button below the program. 3. Enter the uninstall interface and find "View installed updates" in the upper left corner. 4. After entering, you can view the update time in the update information and uninstall all recent updates. Method 2: 1. In addition, we can also directly download the win11 system without updates. 2. This is a product without the most

See all articles