These questions are always asked in PHP intermediate and senior interviews (summary)

I recently experienced interviews and found that there are many shortcomings. We all know that a small business certainly doesn't use a lot of advanced technology, but well, interviews are always a routine. You must master the knowledge of the entire field of PHP. In this way, if the interviewer asks what you answer, basically there is no tension or timidity.

The important point here is to be clear in the expression, otherwise it is not easy to get an offer!


For students who have a poor foundation and do not have a good grasp, you have to work harder, read more and remember some interview questions (this is a method) you can follow the " Programmer Interview Questions A Volume " public account , here Shared various php interview questions.



The following editor summarizes the problems encountered in recent interviews. They are all very real.
Looking at all companies, interviewers will basically ask: How do you optimize the performance of MySQL? Encountered this kind of problem, you will think of query optimization, index optimization

1 Query optimization
Another question: For example, a page responds for a long time, or a SQL query takes a long time, how do you analyze the problem?

Here is a summary for everyone. For details, you can read this article: The PHP website you develop is slow to visit, how do you find the reason ?

Analyzing SQL, we all know that slow query logs will be used, and explain will be used for analysis. Then how do you know that there is no index or redundant fields in a table. . . Specific analysis of specific problems, attach EXPLAIN statement

usage method, add EXPLAIN before the query statement to be executed

EXPLAIN SELECT  * FROM user;

The result is as follows:
Insert picture description here


The following is an explanation of each item:

id The id of the query statement. Simple query is meaningless. When multiple queries are executed, the order of query execution can be seen.
Select-type The type of query statement executed, corresponding to multiple queries, such as simple/primary/union, etc.
Tabel query statement query data table
type The type of data obtained The common type efficiency from high to low is null>const>eq_ref>ref>range>index>all
possible-keys: possible-keys index
key used index
key_len index The length
ref uses which column to select from the table together with the index.
rows find the approximate number of rows of data to be scanned, you can see the pros and cons of the index. The
common ones are
using filesort to query the data and then sort the files, which is slower. You need to optimize the index
using where to read the entire row of data and then judge and filter. Whether it meets the where conditions
using index index coverage, that is, the target data is already stored in the traction, and the index is directly read, very quickly.

MySQL query, the question that the interviewer will raise again:
a large table of millions of data, how do you use paging to query the data, the content corresponding to the specific problem, the editor has also summarized for everyone, you can read this article for details : MySQL millions of data, how do you use paging to query data



Here are a few more query optimization articles, click to view

1 Take a look at how the Great God optimizes and analyzes the SQL query of the 900W+ data table

2 30 MySQL tens of millions of big data SQL query optimization techniques detailed

3 Insert 100,000 data into mysql, how did you achieve it and how to optimize



After analyzing sql above, I will ask how index optimization is optimized.

2 Index optimization
Index optimization is more important. SQL performance is mostly related to indexes. The following summarizes the questions asked by the interviewer in recent interviews. Click the title to view the details

1 Do you know why MySQL index choose B+ tree?

2 Do you know what causes the MySQL index to fail

3 Why MySQL can increase query speed after adding indexes

4 How to index a big data table in an online environment



The above questions are basically to be mastered. After these questions are answered, there are basically no problems. At most, there will be a few more index comparison questions.

Here are some articles on basic indexing issues:

1 MySQL index detailed explanation and index optimization

2 MySQL index, do you know there are several types?

3 mysql performance optimization index optimization

4 Advantages and disadvantages of mysql_ indexing

5 Some key points of mysql table index


In addition to the above two major questions, other individuals feel that they are scattered and scattered. The interviewer will also ask you some questions according to the requirements of their company projects, such
as the design of e-commerce such as sku: product SKU system , How do you design?


The problem of high concurrency will definitely involve locks:
1 MySQL locks (table locks, row locks, pessimistic locks, optimistic locks, gap locks, deadlocks)

2 According to the needs of business scenarios, reasonably use MySQL optimistic and pessimistic locking

3 The idea and source code of Redis to implement distributed locks and task queues

4 High concurrency encounters deadlock and don't know how to solve it. This is enough!


Regarding PHP, the interviewer's questions are inseparable from the basics of php, mainly (click on the title to view)
1 Use of strings : combing and summary of PHP string functions

2 The use of arrays: combing and summary of PHP array functions

3 Regular expressions, especially email: Basic knowledge and application details of php regular expressions

4 session and cookie: take you to understand the difference and usage of session and cookie principle

5 Application of design patterns: I think you still have to understand the common design patterns of PHP!

6 restful api design: the design and style of RESTful Api, you should learn it

7 PHP security issues: What are the common PHP security attacks?


A comprehensive summary of the basics can be viewed from the interview questions:

1 2019 PHP Interview Questions [Basic Part of PHP]

2 2019PHP Interview Questions [Database Part]

3 2019PHP Interview Questions [Object-Oriented Part]

4 Summary of algorithmic questions prepared for the PHP interview



After the interviewer asks about MySQL performance, he will also ask you about redis. We basically use redis for caching. It also has more comprehensive functions and applications, such as message queues, publish message subscriptions, and distributed locks. The summarized article can be viewed by clicking the title

1 What can Redis do? What can't be done?

2 If you have thoroughly understood these Redis knowledge points, the interviewer must think you are very good

3 Why is Redis single-threaded and what factors determine high concurrency?

4 Redis persistence mechanism, advantages and disadvantages, how to choose the right way

5 How to solve the problem of data consistency between Redis cache and MySQL?

6 Redis's concurrent competition problem, what solutions do you use to solve it?

7 How does Redis' memory expiration and elimination strategy work?

8 Have you used redis as an asynchronous queue, how do you use it? What are the disadvantages?

9 If you have thoroughly understood these Redis knowledge points, the interviewer must think you are very good



I use laravel for the framework, so the interviewer will test you based on what you know about the framework. Here is a summary of some of the knowledge of laravel. Click to view
1 If you know all of these in the Laravel framework, you will basically understand its core architecture

2 Some practical Laravel tips

3 Laravel core technology: realize Laravel API authentication based on JWT

4 After using the Laravel framework for so long, have you analyzed the core architecture?

5 Why Laravel will become the most elegant PHP framework


There are not many official accounts for sending PHP technical articles, but the editor has been insisting on choosing articles for everyone, hoping to help you!

Follow the official account, reply to the corresponding number, and get the following video tutorial

1 Vue2.5 core technology source code analysis
Reply in the public account: 19082201

2 Analysis and in-depth interpretation of design pattern examples
. Reply in the public account: 20190714

3 PHP Advanced Practical Tutorial Complete Works
Reply in the public account: 20190625

4 Zero-distance contact with mysql
Reply in the public account: 20190128

5 The actual combat of building a high-performance Linux server
Reply in the public account: 20190622

6 Analysis of the underlying source code of
ThinkPHP5 Reply in the public account: 20190621

7 Thinkphp plug-in development of WeChat system
Reply in the public account: 201907282319

8 Introduction to Laravel basics to actual development in WeChat mall
. Reply in the public account: 08250045

9 PHP Asynchronous Communication Framework Swoole Actual Combat
Reply in the public account: 08250024

Insert picture description here

Guess you like

Origin blog.csdn.net/phpCenter/article/details/105687083