It’s still hot inside the PHP factory! With answers!!!


Please introduce yourself?

A: my name is XXX, I am from Beijing. I graduated from XX computer XX Department in 20XX. I graduated from Wuhan and worked in PHP in X in the past. I am an outsourcing company. I mainly do WeChat development, public number promotion, shopping mall, official account development.


What projects are you in charge of in the company?

A: because our company is an outsourcing company, it is impossible to do only one project. The company’s projects are all cross carried out. Have I done forum, wechat and mall?

Why do you come to Shenzhen?

A: because my brother is here, my parents also want to take care of each other (according to their own hunger). Moreover, Shenzhen is a first tier city, and its technology is more advanced than Guangxi

4. What front-end framework and back-end framework does Wuhan use?

A: answer according to your area

5. What modules have you done?

A: login registration, commodity management, shopping cart module, order management

6. What framework does your company use?

A: our company uses the TP framework, using MySQL + Apache + PHP for development, because the TP framework is a free, open source, lightweight PHP development framework, and it is developed by our Chinese people, and it is also widely used in China, and all kinds of information are relatively complete

7. What is MVC? What is the relationship between them?

A: MVC is a development mode, which is mainly divided into three parts: m (model), that is, model, responsible for data operation; V (view), that is, view, responsible for the front and back display; C (controller), that is, controller, responsible for business logic

The client requests the controller of the project. If the data is needed in the process of execution, the controller will get the data from the model, and then display the data through the view

8. What is OOP?

A: OOP is object-oriented programming. Object oriented programming is a kind of computer programming architecture. One of the basic principles of OOP is that a computer program is composed of a single unit or object that can play the role of a subroutine.

OOP has three characteristics

1. Encapsulation: also known as information hiding, is to separate the use and implementation of a class, leaving only part of the interface and method with external contact, or only exposing some methods for developers. So developers only need to pay attention to how to use this class, and not to care about its specific implementation process. In this way, MVC can achieve division of labor and cooperation, effectively avoid interdependence between programs, and achieve loose coupling between code modules.

2. Inheritance: a subclass automatically inherits properties and methods from its parent class, and can add new properties and methods or rewrite some properties and methods. Inheritance increases the reusability of code. PHP only supports single inheritance, that is to say, a subclass can only have one parent.

3. Polymorphism: subclasses inherit properties and methods from parent classes, and rewrite some of them. Therefore, although many subclasses have the same method, the objects instantiated by these subclasses can get completely different results after calling the same method. This technique is polymorphism. Polymorphism enhances the flexibility of software

3.1 easy maintenance: the structure designed with object-oriented idea has high readability. Due to the existence of inheritance, even if the requirements change, the maintenance is only in the local module, so the maintenance is very convenient and low-cost.

3.2 high quality: when designing, reuse the existing classes that have been tested in previous projects, so that the system can meet the business requirements and have high quality.

3.3 high efficiency: in software development, abstract things in the real world according to the needs of design, and generate classes. Using this method to solve problems, close to daily life and natural way of thinking, is bound to improve the efficiency and quality of software development.

3.4 easy to expand: due to the characteristics of inheritance, encapsulation and polymorphism, a system structure with high cohesion and low coupling is naturally designed, which makes the system more flexible, easier to expand and lower cost.

9. What is smart and what is its function?

A: Answer 1: smart is a template engine written in PHP, and it is also one of the most famous PHP template engines in the industry. It separates logical code from external display, and provides an easy to manage and use method to separate mixed PHP logical code from HTML code

Answer 2: Smarty is one of the most famous engine frameworks in PHP. Our company uses the TP framework and has encapsulated the Smarty template, so it has not been used alone

Answer 3: Smarty is a template engine. The most remarkable thing is that it can cache templates. Generally speaking, a template is to make a static page, and then cut some dynamic parts with all separators. Then open the template file in PHP, replace the values in the separators, and output them. You can see the template part in phplib.

After setting the cache parameters, smart will open the template at the first run time. When PHP replaces the values in it, it will regenerate the read HTML and PHP parts into a temporary PHP file, which saves the need to reread the HTML every time it is opened. If you modify the template, just brush it again.

10. What are the advantages of TP framework?

A: the TP framework is a framework developed by the Chinese themselves. It has a complete range of materials and is widely used in China. It is relatively simple and convenient, and it is free and open source

11. What are the characteristics of TP?


  1. Multi table query is very convenient. In the model, a few sentences of code can complete the operation of multi table Association
  2. The smart template is integrated to separate the front and background
  3. The naming rules, models, views and controllers strictly follow the naming rules and correspond one by one through naming
  4. The naming rules, models, views and controllers strictly follow the naming rules and correspond one by one through naming
  5. Support multiple URL modes
  6. Built in Ajax return methods, including XML, JSON, HTML, etc
  7. Support application extension, class library extension, driver extension, etc

12. Big letter function in TP framework?

A: u: assembly of URL
A: Internal instantiation controller
S: Cache processing
R: Call the operation method of a controller
D: Instantiate a custom model class
M: Instantiate basic model class
1: Get parameters
50: Set or get the current language
C: Set or get, save configuration

13. What about the laravel framework?

A: the design idea of laravel framework is relatively advanced, which is very suitable for various development modes. As a framework, it is ready for you. Composer is the future of PHP.

The biggest feature and excellence of laravel framework is the collection of relatively new features of PHP, as well as a variety of design patterns, IOC patterns, dependency injection and so on

14. What are the characteristics of laravel?

Answer 1:

  1. Powerful rest Router: it can be called with a simple callback function to quickly bind controller and router
  2. Artisan: command line tools, a lot of manual work is automated
  3. Inheritable template simplifies the development and management of view
  4. Blade template: faster rendering
  5. ORM operation data
  6. Migration: managing database and version control
  7. The test function is also very powerful
  8. Composer is also a bright spot

Answer 2: the laravel framework introduces facade, dependency injection, IOC pattern, and various design patterns

15. Please describe the optimization of database?

A: there are four ways to optimize the database

  1. From the structure layer: the web server uses load balancing server, MySQL server uses master-slave replication, read-write separation
  2. From the storage layer: using appropriate storage engine, using three paradigms
  3. From the design layer: partition, table, index, table field, appropriate field properties, appropriate reverse normal form, open MySQL cache
  4. SQL statement layer: in the case of the same result, the SQL statement with high efficiency, fast speed and resource saving is adopted

16. How to solve exception handling?

A: throw an exception: use try… Catch to put the exception code in the try code block. If the exception is not triggered, the code will continue to execute. If the exception is triggered, an exception will be thrown. The catch code block catches the exception and creates an object that contains the exception information. $e – > getmessage(), output abnormal error information.

Solving exceptions: using set_ error_ The handler function gets the exception (you can also use the try() and catch() functions), and then use set_ exception_ The handler() function sets the default exception handler, register_ shutdown_ Function () function to execute. The execution mechanism is that PHP calls the function into memory. When all PHP statements on the page are executed, this function is called again

17. Front end

A: in my work, I deal with the front-end function. Generally, I use ajax to request data from the background, and then return the data to display in the front page. I have never independently and completely completed HTML and CSS styles by myself. If the company has such a demand, I may find some front-end templates or front-end frameworks, such as h-ui and so on

18. Implementation of RBAC?


  1. First, create a user table: ID name auto (save format: controller method)
  2. Then, a base class controller is created in the background, and a construction method is encapsulated in the controller. When the user logs in successfully, the session ID stored in the server is obtained by using the session function encapsulated in the TP framework, and then the model is instantiated. The auth data stored in the data table is obtained by using the user ID, and the data obtained is segmented by using the expand function, And use an array to save it, then use the encapsulated constant in TP framework to get the current controller and method, and then assemble them into a string, using in_ The array function is used to determine whether the array contains the currently acquired controller and method. If not, it will prompt that the user does not have permission. If so, it will proceed to the next operation

19. The realization of payment function?


20. How to ensure that the promotion products will not oversold

A: this problem was a difficulty we encountered in the development at that time. The reason for oversold was mainly due to the inconsistency between the number of orders placed and the number of goods we wanted to promote. Each time, the number of orders was always more than the number of goods we promoted. At that time, our group discussed for a long time and gave several solutions

The first scheme is: ① before placing an order, we judge whether the quantity of promotional products is enough or not, and we are not allowed to place an order. When we change the inventory, we add a condition to change only the inventory of products whose inventory is greater than 0. At that time, we used AB for stress test. When the concurrency is more than 500 and the number of visits is more than 2000, there will still be oversold. So it was denied by us.

The second solution is: 2. Using MySQL transaction and exclusive lock to solve the problem. First of all, we choose InnoDB as the storage engine of the database, which is implemented by exclusive lock. At the beginning, we tested the shared lock, and found that there will still be oversold. One problem is that when we conduct high concurrency testing, it has a great impact on the performance of the database, resulting in a great pressure on the database, which is eventually denied by us.

The third scheme is: 3. Using file lock. When a user grabs a promotional product, the file lock is triggered first to prevent other users from entering. After the user grabs the promotional product, the file lock is unlocked and other users are put to operate. This can solve the problem of oversold, but it will lead to file I / O overhead.

Finally, we use the redis queue to implement. The number of products to be promoted is stored in redis in the form of queue. Every time a user grabs a promotion product, a data is deleted from the queue to ensure that the product will not oversold. This operation is very convenient and highly efficient, and finally we take this way to achieve

21. The realization of seckill in shopping mall

A: Rush buying and second killing are very common application scenarios nowadays. There are two main problems to be solved

  1. The pressure of high concurrency on Database
  2. How to solve the problem of “oversold” in inventory reduction under Competition

For the first problem, it’s easy to think of using cache to deal with panic buying, and avoid directly operating the database, such as redis.

The second problem is that we can use the redis queue to put the goods to be killed in seconds into the queue, because the pop operation is atomic. Even if many users arrive at the same time, they are executed in turn. The performance of file locks and transactions declines rapidly when they are high. Of course, we also need to consider other things, such as making the snapping page static, using Ajax Call the interface, in which there may be a case of a user grabbing many times. At this time, you need to add a queue, a result queue and an inventory queue. In the case of high concurrency, the user is put into the queue, and a user is taken out from the queue with a thread loop processing, so as to judge whether the user is already in the result queue. If so, the user has been snapped up, otherwise, the user is not snapped up, the inventory is reduced by 1, and the user is put into the result queue by writing to the database.

22. Principle of shopping cart

A: a shopping cart is equivalent to a supermarket shopping cart in reality. The difference is that one is a physical car and the other is a virtual car. Users can jump between different pages of the shopping website to choose their favorite products. When they click to purchase, the products will be automatically saved to your shopping cart. After repeated purchase, all the selected products will be put in the shopping cart and paid at the checkout counter. This is also to let customers experience the feeling of shopping in real life as much as possible. By tracking the actions of each user, the server ensures that each item has its own owner when checking out.

It mainly involves the following points:

  1. Add the item to the shopping cart, that is, order
  2. Delete ordered items in shopping cart
  3. Modify the order quantity of a book in the shopping cart
  4. empty cart
  5. Display the list, quantity and price of goods in the shopping cart

The key to the implementation of shopping cart is that the server identifies each user and maintains contact with them. But HTTP protocol is a kind of “stateless” protocol, so the server can’t remember who is buying goods. When the goods are added to the shopping cart, the server doesn’t know what is in the shopping cart, which makes the shopping cart can’t be “taken with you” when users jump between different pages, which makes it difficult to realize the shopping cart.

At present, shopping cart is mainly realized by cookie, session or database. The following is an analysis of their mechanisms and functions.


A cookie is a piece of information generated by the server and stored in the client. It defines a mechanism for web server to store and return information on client. Cookie file contains domain, path, lifetime and variable value set by server. When users visit the same web server later, the browser will send the cookie to the server as it is. By allowing the server to read the information originally saved to the client, the website can provide a series of convenience for the browser, such as identifying the user’s identity in the process of online transactions, avoiding the repeated input of the user’s name and password when the security requirements are not high, customizing the home page of the portal, targeted advertising, etc. With the characteristics of cookie, the function of web application is greatly expanded. It can not only establish the connection between the server and the client, because the cookie can be customized by the server, but also store the cookie value generated by shopping information in the client, so as to realize the function of shopping cart. Using cookie based method to realize the conversation or shopping cart between the server and the browser has the following characteristics:

(1) Cookies are stored in the client and occupy very few resources. The browser is allowed to store 300 cookies, and the size of each cookie is 4KB, which is enough to meet the requirements of the shopping cart and reduce the load of the server;

(2) Cookies are built into the browser and easy to use. Even if the user accidentally closes the browser window, the information in the shopping cart will not be lost as long as it is within the validity period defined by the cookie;

(3) Cookie is not an executable file, so it will not be executed in any way, so it will not bring virus or attack the user’s system;

(4) Cookie based shopping cart requires that the user’s browser must support and enable cookie, otherwise the shopping cart will be invalid;

(5) There is a dispute that cookies infringe the privacy of visitors, so some users will prohibit the cookie function of this machine.


Session is another way to implement shopping cart. Session provides the function of saving and tracking the user’s state information, so that the variables and objects defined by the current user in session can be shared between pages, but can not be accessed by other users in the application. The most important difference between session and cookie is that session stores the user’s private information in the server during the session, which improves the security. After the server generates a session, the client will generate a session ID and save it in the client to keep the synchronization with the server. This session ID is read-only. If the client forbids the cookie function, the session will be transmitted between pages by appending parameters in the URL, or submitting in the form. Therefore, using session to manage users is more secure and effective.

Similarly, session can also be used to realize shopping cart

(1) Session uses a new mechanism to keep synchronization with the client, independent of the client settings;

(2) Compared with cookie, session is the information stored in the server, so it is more secure. Therefore, identity, shopping and other information can be stored in session;

(3) Session will occupy the server resources and increase the load of the server, especially when there are many concurrent users, it will generate a large number of sessions and affect the performance of the server;

(4) Because the information stored in session is more sensitive and stored in the server as a file, there are still security risks.

3. Combined with database

In this way, the database is used to store shopping information, while session or cookie is used to track users. This method has the following characteristics:

(1) Database and cookie are responsible for recording data and maintaining session respectively, which can give full play to their respective advantages and improve the security and server performance;

(2) Every shopping behavior needs to establish a connection with the database directly. The connection will not be released until the operation on the table is completed. When there are many concurrent users, it will affect the performance of the database. Therefore, it puts forward higher requirements for the performance of the database;

(3) Keeping a cookie session depends on client support.

Selection of various methods:

Although cookie can be used to realize shopping cart, it must be supported by browser. Moreover, it is the information stored in the client, which is very easy to be obtained, so it also limits it to store more and more important information. So generally, cookies are only used to maintain the session with the server. For example, the largest Dangdang online bookstore in China uses cookies to keep in touch with customers. But the biggest disadvantage of this method is that if the client does not support cookies, it will make the shopping cart invalid.

Session can keep a good conversation with both sides of the transaction, and the client settings can be ignored. It has been widely used in shopping cart technology. However, the file attribute of session still leaves security risks.

Although the combination of database solves the above problems to a certain extent, it can be seen from the above examples that frequent operation of database tables is involved in this shopping process, especially when users purchase goods every time, they have to connect with the database. When there are many users, the load of server and database is increased.

23. What should be paid attention to in first out of redis message queue

A: usually, a list is used to implement queue operation, so there is a small limit. All tasks are FIFO. If you want to give priority to a task, it’s not easy to deal with it. Therefore, we need to give priority to high-level tasks by giving priority to the queue

1) Single list implementation: the normal operation of the queue is left in right out (lpush, rpop). In order to deal with high priority tasks first, when encountering high-level tasks, you can directly jump in the queue and put them into the queue head (rpush). In this way, when getting tasks from the queue head (right), you will get high priority tasks (rpop)

2) Using two queues, an ordinary queue and an advanced queue, you can put them into different queues according to the level of the task. It is also very simple to get the task. The brpop command of redis can take values from multiple queues in order. Brpop will view them in the order given by the key, and pop up an element at the end of the first non empty list, redis > brpop LIST1 List2 0

LIST1 as high priority task queue

List2 as a common task queue

In this way, we can deal with high priority tasks first, and get common tasks when there are no high priority tasks

Mode 1 is the simplest, but the practical application is limited. Mode 3 can realize complex priority, but the implementation is complex, which is not conducive to maintenance

Mode 2 is the recommended usage, which is most suitable for practical application

24. What are the problems with your module

A: in B2B, which I am responsible for In the e-commerce project, I was responsible for the order module at that time. Because the customer selected the goods of multiple merchants at one time and finally generated an order, our platform didn’t know which merchant should pay for the cost when settling the accounts for the merchants. At this time, our group discussed that it was necessary to split the order, that is, after the user click to pay, If there are multiple items and they are not in the same store, order splitting will be used. For example, if there are two items and they are not in the same store, two sub order numbers will be generated under the original order number and the order number of two items in the order table will be modified. Finally, we realized the distribution management of goods and solved our problems.

In my opinion, there are no more than two problems in the development process. One is technical level. As long as you have perseverance and enthusiasm, there are no problems you can’t feel. Another problem is communication. Communication is the most important anywhere and at any time, especially when we are developing. If we don’t communicate well, it will affect the progress of the whole project. I am a very communicative person, so there is no big problem on this point.

25. How do users handle orders

A: judge whether the user has logged in or not. In the case of not logging in, it is not allowed to place an order. After logging in, you can place an order and generate a unique order number. At this time, the status of the order is unpaid.

26. How is the login of e-commerce realized

A: it is divided into ordinary login and third-party login. Here we mainly talk about the third-party login. The third-party login mainly uses the author protocol. I will take the third-party login of QQ as an example to illustrate: when users request the third-party login of QQ in our site, our site will guide users to jump to the login authorization interface of QQ, when users enter QQ After successfully logging in with the password, you will automatically jump back to the callback page set by our site, with a code parameter. Then you use the code to request the authorization page of QQ again, and you can get an access token from it_ Token, we can call the interface provided by QQ, such as getting open_ ID, you can get the basic information of the user. After obtaining it, we need to get the user’s authorization information and open_ ID is bound to ordinary users of our platform. In this way, both ordinary users and third-party users can log in.

27. How to deal with interface security

A: we did this at that time. We used the HTTP post method to digitally sign the fixed parameters and additional parameters. We used MD5 encryption. For example, I want to get an information through the title, use the information title + date + a key agreed by both parties on the client, generate a signature through MD5 encryption, and then pass it to the server as a parameter, The server uses the same method for verification. Only when the received sign is the same as the value calculated by our algorithm and it is proved to be a normal interface request, can we return the corresponding interface data.

28. What technology is used to send SMS and where to call it

A: I mainly use the third-party SMS interface. When I apply for the interface, I configure the corresponding information, and then call it where we need SMS verification. We usually use it when users register.

29. What difficulties have you encountered in your work?

A: Generally speaking, I mainly encounter these problems in my work

① When I worked before, I found that there were often some temporary needs that disrupted my plan. Sometimes this task had not been completed, and I had to do other tasks. At the end of the day, there were many big and small things, but they were not completed very well. Later, I summarized, I would add these to the priority, and when meeting the temporary needs, I would follow the priority Rearrange the existing tasks and temporary tasks to ensure the efficient completion of high priority tasks within the specified time.

② When doing the project needs, when meeting people with poor understanding ability, they are easy to be angry when communicating, which will affect their emotions. In the end, they can not achieve the desired effect. Later, when it comes to this kind of time, I usually use some paper and more vivid things to communicate in a way that both sides agree and understand, which reduces a lot of unnecessary trouble. As we all know, for programmers, changing requirements is a very painful thing, so the early communication work is very important.

③ Another thing is that my former leaders didn’t know much about technology, so every time a new requirement came out, they always asked us to complete it in a very short time. If we couldn’t complete it, we would be suspected that there was a problem with our ability. Of course, every leader wants his staff to complete the task as soon as possible, reduce costs and improve efficiency. At this time, I will refine our requirements, list out the key points and difficulties, do a good job in time planning, patiently communicate with the leaders, the importance of each point of the project and the proportion of time spent, so as to ensure that the task can be completed with quality and quantity within the planned time point. In fact, the leadership is not blindly unreasonable. As long as we plan things well and exchange the lowest cost for the highest value, everyone can easily understand it

30. How can a user join the shopping cart without logging in

A: without logging in, the user can send the information of the goods to be purchased (such as the ID, price and SKU of the goods)_ Key data (such as ID, purchase quantity, etc.) are stored in the cookie, when logging in. Store the contents of cookie in database and clear the data in cookie.

31. Have you ever written an interface? How to define an interface

A: Yes. There are two kinds of interfaces: one is data interface, the other is application interface.

Data interface: it is a kind of “structure” more abstract than abstract class. It is not a class, but a kind of syntax structure similar to class. It is a kind of structure specification, which specifies the format of our class. It is generally used when the team is large and there are many branches.

Application interface: an entry for API data access

I am mainly involved in the preparation of the interface in the development of app. We will provide them with the corresponding data of what kind of data the client needs. The data is returned in the format of JSON / XML, and matched with the corresponding interface documents.

32. SKU less inventory

Answer: SKU = stock keeping unit

That is, the unit of inventory in and out measurement, can be in pieces, boxes, pallets and other units. SKU is the unit of inventory quantity, which distinguishes the items.
It is widely used in clothing and shoes. For example, a SKU in textiles usually means: specification, color and style.

When designing a table, there is not only a commodity table, but also a total inventory in the commodity table. We also need to involve a SKU table, which has SKU inventory and unit price fields. Every time a user purchases a commodity, what he actually purchases is a SKU commodity. In this way, after placing an order successfully, the corresponding SKU should be performed according to the unique SKU number of the purchased commodity The reduction of inventory, of course, the total inventory of goods is saved in the main table of goods, also need to reduce the inventory in the total inventory.

33. Inventory settings?

A: inventory is divided into total merchandise inventory and SKU inventory. The total merchandise inventory is usually the sum of SKU inventory. Generally, after setting the maximum inventory and minimum inventory for goods in the back office of the mall, the current inventory quantity is compared with the maximum and minimum. If the inventory quantity exceeds or is lower than the inventory, it will be reflected in the form of a report, which is convenient for users to master the status and quantity of goods in excess or shortage.

34. How to ensure the consistency of data in order and inventory tables?

A: in an e-commerce system, it is normal to reduce the corresponding inventory after the order is successfully generated. It is necessary to ensure the consistency of the two, but sometimes for some reasons, such as program logic problems, concurrency and other problems, the order is successful and the inventory is not reduced. This situation is not allowed to happen. Transactions in MySQL can just solve this problem. First of all, we have to select InnoDB as the storage engine of the database. Transactions stipulate that transactions can only be submitted when the order is completed and the corresponding inventory is reduced. Otherwise, transactions will be rolled back to ensure data consistency.

35. When o2o users place orders and C-end places orders, how to ensure the consistency of b-end and a-end data?

A: o2o is an online and offline mode. The o2o mode pursues the consumption mode of “online payment + physical store consumption”, that is, after consumers place an order online and complete the payment, they will go to the physical store for consumption with the consumption certificate. O2o mode is to put the business information and payment procedures online, and to cash goods and services offline. That is to say, o2o mode is applicable to tangible products that cannot be delivered by express. Data consistency is the most common problem in o2o industry. We can solve this problem similar to master-slave replication of database. O2o has a supplier system, which is similar to the master server. When placing an order at the C end (the slave server), the data is synchronously updated to the supplier system. B and a pull the data from the supplier system in real time for synchronization, such as using the timing task to pull the data regularly for synchronization.

36. How to prevent high concurrency in redis

A: actually, there is no concurrency problem in redis, because redis is a single process, and any number of commands are executed by one by one. When we use it, there may be concurrency problems, such as get and set.

Why does redis have high concurrency

The origin of redis

Redis is a NoSQL database with single thread mechanism. Based on key value, the data can be persistently dropped. Because of the single thread, redis itself does not have the concept of lock, and there is no competition between multiple client connections. However, there will be problems when using jedis and other clients to access redis concurrently. There are many problems, such as connection timeout, data conversion error, blocking, client closing connection, etc. these problems are caused by the confusion of client connection.

At the same time, the nature of single thread determines that high concurrency operations on the same key will be queued. If the amount of concurrency is large, it may cause subsequent request timeout.

When accessing redis remotely, the problem of high concurrent access delay return is caused by network and other reasons.

terms of settlement

In the client, the connection is pooled, and the read-write redis operation of the client is synchronized by internal lock.

From the perspective of server, using setnx to change direction to realize the lock mechanism.

37. How do you get the details of the second kill

A: through performance test and Simulation of seckill scene. Every problem has been repeatedly tested, constantly found problems, and constantly solved.

38. What kind of database is used for seckill and how to realize it.

A: because the concurrency is very large at the moment of second kill, if the database is requested at the same time, the pressure on the database will be very high, resulting in a sharp decline in the performance of the database, and even more serious, the database server may be down. At this time, the memory cache database redis is generally used. Redis is a non relational database, and redis is a single thread. The second kill process can be completed through the redis queue.

39. how to realize Alipay process?

Answer: first, we must have a Alipay account, then apply to Alipay for online payment business and sign the agreement. After the agreement comes into effect, the Alipay side will give the website partner a ID and a security check code. With these two things, you can develop the Alipay interface according to the Alipay interface document, and the middle is mainly related to a security problem. The whole process is like this: our website passes the corresponding parameters (such as the total amount of the order, order number) to the payment page through post, and the payment page processes a series of parameters to post The method is submitted to the Alipay server, the Alipay server is verified, and the received data is processed, and the processed results are returned to the asynchronous and synchronous callback addresses set up by our website, and the corresponding business logic is processed through the corresponding return parameters, such as the return parameters representing the successful payment and the change of the order status.

40. What is single sign on?

A: the simple point of single sign on (SSO) is that in an environment where multiple systems coexist, users do not have to log in to other systems after logging in at one place, that is, users can get the trust of all other systems after logging in at one time.

41. When to use caching

A: when the user visits the application system for the first time, because he has not logged in yet, he will be guided to the authentication system to log in. According to the login information provided by the user, the authentication system will verify his identity. If he passes the verification, he should return an authentication credential ticket to the user. When the user visits other applications, he will return the ticket With, as their own authentication credentials, the application system will send the ticket to the authentication system for verification after receiving the request to check the legitimacy of the ticket. If the verification is passed, the user can access application system 2 and application system 3 without logging in again.

The main technical points are as follows

  1. Two stations share one data verification system
  2. Mainly through the way of cross domain request to achieve verification and session processing.

42. How to realize the third party login?

A: the third party login is mainly based on the author protocol. The implementation process is as follows:

  1. First of all, we need to apply for access to the application from the third-party login platform as a developer. After the application is successful, we will get an appid and a secrectid
  2. When our website needs to access the third party login, it will guide users to jump to the login authorization page of the third party, and then bring the previously applied appid and secrectid to the login authorization page.
  3. After successful login, the user will be authorized, and the third party will return a temporary code to our website.
  4. After receiving the code, our website sends a request to our third party again, and carries the received code to obtain access from the third party_ token.
  5. After the third party processes the request, it returns an access_ Token to our website, our website access_ After token, you can call the interface provided by a third party, such as obtaining user information. Finally, the user’s information is stored in the database of our site, and the information is saved in the session to realize the user’s third-party login.

43. How to deal with load and high concurrency? (take a good look, ask frequently, and answer the main things)

A: from the perspective of low cost, high performance and high scalability, there are the following solutions:

1. Static HTML

In fact, we all know that the most efficient and the least consumption is the pure static HTML page, so we try our best to make the page on our website use the static page to achieve, the simplest method is actually the most effective method.

2. Image server separation

The pictures can be stored separately to minimize the cost of large traffic such as pictures, which can be put on some related platforms, such as riding cattle, etc

3. Database cluster, hash and cache of database table

The concurrent connection of the database is 100, and one database is far from enough. We can start from the aspects of read-write separation, master-slave replication, and database cluster. In addition, try to reduce database access, you can use cache database, such as Memcache, redis.

4. Image:

Minimize the number of downloads, and distribute different requests to multiple mirrors.

5. Database optimization

6. Load balancing:

Apache’s maximum concurrent connection is 1500. You can only add servers. You can start with hardware, such as F5 server. Of course, the cost of hardware is relatively high, we often start from the software.

Load balancing is based on the existing network structure. It provides a cheap, effective and transparent method to expand the bandwidth of network devices and servers, increase the throughput, strengthen the network data processing capacity, and improve the flexibility and availability of the network. At present, the most widely used load balancing software is nginx, LVS and haproxy. I would like to talk about the advantages and disadvantages of the following three categories:

The advantages of nginx are:

  1. Working on the seven layers of the network, we can do some streaming strategies for HTTP applications, such as domain name and directory structure. Its regular rules are more powerful and flexible than haproxy, which is one of the main reasons why it is widely popular. Nginx can make use of more fields than LVS.
  2. Nginx relies very little on network stability. Theoretically, it can carry out load function by pinging, which is also one of its advantages. On the contrary, LVS relies more on network stability, which I deeply understand;
  3. Nginx is easy to install and configure, and easy to test. It can basically print out errors with logs. The configuration and testing of LVS will take a long time, and LVS relies heavily on the network.
  4. It can bear high load pressure and is stable. It can support tens of thousands of concurrent times when the hardware is not bad, and the load degree is relatively smaller than LVS.
  5. Nginx can detect the internal faults of the server through the port, such as the status code returned from the web page processed by the server, timeout and so on, and will re submit the wrong request to another node, but the disadvantage is that it does not support URL detection. For example, if a user is uploading a file and the node that handles the upload fails during the upload process, nginx will switch the upload to another server for reprocessing, and LVS will be broken directly. If a large file or important file is uploaded, the user may be dissatisfied.
  6. Nginx is not only an excellent load balancer / reverse proxy software, but also a powerful web application server. LNMP is also a very popular web architecture in recent years, and it has good stability in high traffic environment.
  7. Nginx is becoming more and more mature as a web reverse cache, which is faster than the traditional squid server, so it can be considered as a reverse proxy accelerator.
  8. Nginx can be used as a middle-level reverse proxy. At this level, nginx basically has no rival. Lighttpd is the only one that can compare with nginx. However, lighttpd has not achieved the full function of nginx, the configuration is not so clear and easy to read, and the community information is far less active than nginx.
  9. Nginx can also be used as a static web page and image server, and its performance is no match. Also, the nginx community is very active, and there are many third-party modules.

The disadvantages of nginx are:

  1. Nginx only supports HTTP, HTTPS and email protocols, so it has a smaller scope of application. This is its disadvantage.
  2. For back-end server health check, only port detection is supported, not URL detection. It does not support the direct holding of session, but it can be maintained through IP_ Hash.

LVS: using Linux kernel cluster to realize a high performance and high availability load balancing server, it has good scalability, reliability and manageability.

The advantages of LVS are:

  1. It has strong anti load capability, works on the four layers of the network, only for distribution, and has no traffic generation. This characteristic also determines that it has the strongest performance in the load balancing software, and has low consumption of memory and CPU resources.
  2. The configuration is relatively low, which is a disadvantage and an advantage. Because there are not too many things to configure, it does not need too much contact, greatly reducing the probability of human error.
  3. It works stably because of its strong anti load capability and has a complete dual machine hot standby scheme, such as LVS + kept. However, LVS / DR + kept is the one we use most in project implementation.
  4. No traffic, LVS only distributes requests, and traffic does not go out from itself, which ensures that the performance of equalizer IO will not be affected by large traffic.
  5. LVS has a wide range of applications. Because LVS works in four layers, it can balance the load of almost all applications, including HTTP, database, online chat room and so on.

The disadvantages of LVS are:

  1. The software itself doesn’t support regular expression processing, and it can’t separate dynamic from static. Now many websites have strong demand in this aspect, which is the advantage of nginx / haproxy + preserved.
  2. If the website application is relatively large, the implementation of LVS / DR + kept will be more complicated. Especially if there are windows server machines behind, the implementation, configuration and maintenance process will be more complicated. Relatively speaking, nginx / haproxy + kept will be much simpler.

The characteristics of haproxy are as follows:

  1. Haproxy also supports virtual hosts.
  2. The advantages of haproxy can complement some disadvantages of nginx, such as supporting session retention and cookie boot, and detecting the state of back-end server by obtaining the specified URL.
  3. Haproxy, like LVS, is just a load balancing software in itself. In terms of efficiency, haproxy has better load balancing speed than nginx, and it is also better than nginx in concurrent processing.
  4. Haproxy supports load balancing forwarding of TCP protocol. It can load balance MySQL read, detect and load balance MySQL nodes at the back end. You can use LVS + preserved to load balance MySQL master-slave.
  5. There are many load balancing strategies for haproxy. There are eight load balancing algorithms for haproxy

① Roundrobin, which means simple polling, is a basic feature of load balancing;

② Static RR, which means to recommend attention according to weight;

③ Leastconn, which means that the least connected should be dealt with first, and it is recommended to pay attention to;

④ Source: according to the request source IP, this is the same as nginx’s IP_ Hash mechanism is similar, we use it as a method to solve the session problem, and we suggest to pay attention to it;

⑤ RI, which represents the URI based on the request;

⑥ rl_ Param, which means according to the URL parameter ‘balance URL’ of the request_ param’ requires an URL parameter name;

⑦ HDR (name), which means to lock every HTTP request according to the HTTP request header;

⑧ RDP cookie (name) means to lock and hash every TCP request according to the cookie (name).

Summary of comparison between nginx and LVS:

  1. Nginx works in the 7 layers of the network, so it can make streaming strategies for HTTP applications, such as domain name and directory structure. In contrast, LVS does not have such functions, so nginx can be used in more occasions than LVS alone. However, the useful functions of nginx make it more adjustable than LVS LVS, so often to touch, touch more, the probability of artificial problems will be large.
  2. Nginx is less dependent on the stability of the network. In theory, as long as Ping is available and web page access is normal, nginx can be connected. This is one of the advantages of nginx! Nginx can also distinguish between internal and external networks. If you have nodes of internal and external networks at the same time, it means that a single machine has a backup line. LVS is more dependent on the network environment. At present, the server is in the same network segment, and LVS uses direct mode to shunt, so the effect can be guaranteed. In addition, it should be noted that LVS needs to apply at least one more IP from the hosting provider to do visual IP. It seems that LVS cannot use its own IP to do VIP. To be a good LVS administrator, you really have to follow up and learn a lot about network communication, which is no longer as simple as HTTP.
  3. Nginx is easy to install and configure, and easy to test, because it can basically print out errors with logs. The installation, configuration and testing of LVS will take a long time; LVS relies heavily on the network, and many times it can’t be configured successfully because of network problems rather than configuration problems, and it will be much more troublesome to solve problems.
  4. Nginx can also bear high load and stability, but the load and stability are poor. LVS has several levels: nginx handles all traffic, so it is limited by machine IO and configuration; its own bugs are also unavoidable.
  5. Nginx can detect the internal faults of the server, such as the status code returned from the web page processed by the server, timeout and so on, and will re submit the wrong request to another node. At present, ldirectd in LVS can also support monitoring the internal situation of the server, but the principle of LVS makes it unable to resend the request. For example, if a user is uploading a file and the node handling the upload fails during the upload process, nginx will switch the upload to another server for reprocessing, and LVS will be broken directly. If a large file or important file is uploaded, the user may be annoyed.
  6. The asynchronous processing of requests by nginx can help the node server reduce the load. If you use Apache to directly serve the outside world, then when there are many narrow-band links, the Apache server will occupy a lot of memory and can’t release them. If you use one more nginx as the Apache proxy, these narrow-band links will be blocked by nginx, and the Apache server will be unable to release them There will not be too many requests on the server, which will reduce the resource consumption. Using squid in this point has the same effect. Even if squid itself is configured not to cache, it is very helpful for Apache.
  7. Nginx can support HTTP, HTTPS and email (email function is less used), LVS will support more applications than nginx in this respect. In terms of use, generally the front-end strategy should be LVS, that is, DNS should point to LVS equalizer. The advantages of LVS make it very suitable for this task. Important IP addresses should be managed by LVS, such as IP of database, IP of web service server, etc. as time goes on, these IP addresses will be used more and more widely. If the IP is replaced, the failure will follow. Therefore, it is the most secure to entrust these important IP to LVS for hosting. The only disadvantage of this is that the number of VIP will be relatively large. Nginx can be used as LVS node machine, one is to use the function of nginx, the other is to use the performance of nginx. Of course, squid can also be used directly at this level. The function of squid is much weaker than that of nginx, and its performance is also inferior to that of nginx. Nginx can also be used as a middle-level agent. At this level, nginx basically has no rival. The only thing that can shake nginx is lighttpd. However, lighttpd has not been able to achieve the full functions of nginx, and the configuration is not so clear and easy to read. In addition, the IP of the middle-level agent is also important, so the middle-level agent also has a VIP and LVS, which is the most perfect solution. Specific applications need to be analyzed in detail. If it’s a relatively small website (daily PV is less than 10 million), it’s OK to use nginx. If there are many machines, you can use DNS polling, and LVS consumes more machines. For large websites or important services, when machines don’t worry, you should consider using LVS more.

44. Do you think about locking your watch when doing second kill?

A: Yes. At that time, we considered several solutions when we did second kill, one of which was to use transaction and exclusive lock.

Have you ever been in touch with architecture?

Yes, I have. I have configured it on my own server. I have done the following configuration and testing of architecture before;

  1. Read and write separation, master-slave replication and cluster of database.
  2. Nginx load balancing
  3. Redis cluster and master slave

45. Encapsulate a simple framework

A: it has encapsulated a simple MVC framework, which is mainly divided into three layers: controller layer, model layer, view layer, routing allocation and entry file, template engine, singleton mode, factory mode, introduction of third-party class library, etc.

46. Talk about the understanding of MVC

A: the core idea is that the view and user interact through events to cause the controller to change, the controller changes to cause the model to change, or the controller changes both at the same time. The model changes to cause the view to change, or the view to change. Potentially, you can get parameters from the model to change yourself. Its advantage is that it can separate the interface from the business logic.

Model is the main part of the program, mainly including business data and business logic. In the model layer, services published by users are also involved. In the service, data in the business model will be updated according to different business requirements.

View is the part of the program presented to the user and the interface between the user and the program. According to the specific business needs, the user will input their own specific business data in the view layer, and submit the corresponding input parameters to the background controller for processing through the event interaction of the interface.

Contoller (controller), which is used to process user input data, has updated the business model. The controller receives the data from the interaction between the user and the interface, and performs the service call and updates the data and status of the business model according to the data business logic.

47. The difference between session and cookie


1. The cookie data is stored in the browser of the third party application, and the session data is placed on the server.
2. Cookies are not very secure. Others can analyze the local cookies and cheat them

Session should be used for security.
3. The session will be saved on the server for a certain period of time. When access increases, it will take up the performance of your server

In order to reduce server performance, you should use cookie.
4. A single cookie can’t save more than 4K data. Many browsers limit a site to save up to 20 cookies.
5. So I suggest that:
Save important information such as login information as session
If you need to keep other information, you can put it in cookie

48.echo(),print(),print_ The difference between R and R

A: echo can output multiple values at one time, separated by commas. Echo is a language structure, not a real function, so it cannot be used as part of an expression. Echo is an internal instruction of PHP, not a function, with no return value.

Print(): the function print() prints a value (its parameter). If the string is displayed successfully, it returns true, otherwise it returns false. Only the values of simple type variables (such as int, string) can be printed, with return values

Printf(): from printf() in C language. This function outputs a formatted string.

print_ R () and VaR_ dump()

print_ R () can simply print out strings and numbers, while arrays are displayed as a list of enclosed keys and values, beginning with array. But print_ It is meaningless for R () to output Boolean and null results, because both are printed “\ n”. So we use var_ The dump() function is more suitable for debugging. print_ R is a function that can print out complex variables (such as arrays and objects) with return values

var_ Dump () judges the type and length of a variable, and outputs the value of the variable. If the variable has a value, it outputs the value of the variable and returns the data type. This function displays structural information about one or more expressions, including the type and value of the expression. The array will expand the value recursively and show its structure by indentation.

49. Say a single quote double quote?

Answer: ① variables inside single quotation marks will not be executed, while double quotation marks will be executed

② The parsing speed of single quotation mark is faster than that of double quotation mark.

③ Single quotation marks can only parse some special characters, while double quotation marks can parse all special characters.

50. Advantages and disadvantages of index

A: 1. Advantages:

a) It can ensure the uniqueness of the data in each row of the database table

b) It can greatly speed up the indexing speed of data

c) The connection between accelerometers and tables is particularly significant in realizing the referential completion of data

d) When grouping and sorting clauses are used for data retrieval, the time of grouping and sorting can also be significantly reduced

f) By using the index, we can use the optimized Concealer in the process of time query to improve the performance of the system

2. Disadvantages:

a) It takes time to create and maintain indexes, which increases with the increase of data volume

b) Indexes need to occupy physical space. In addition to the data space occupied by data tables, each index also needs to occupy a certain amount of physical space. If clustering indexes need to be established, the space occupied will be larger

c) When adding, deleting and modifying data in a table, the index should be maintained dynamically, which reduces the speed of integer maintenance

d) Principles of indexing

e) You can speed up the search on the columns that often need to be searched

f) On a primary key column, the uniqueness of the column and the arrangement structure of the data in the organization table are enforced

g) These columns are mainly foreign keys, which can speed up the connection

h) Indexes are created on columns that often need to be searched by range. The country index is sorted and its specified range is continuous

i) On the columns that often need to be sorted, the Guowei index has been sorted, so that the bottom hole can use the sorting of the index to speed up the bottom hole sorting time

j) In the column which is often used in where clause, the speed of judging condition is accelerated

51. The difference between get and post


  1. Get is to get data from the server, post is to send data to the server.
  2. Get is to add the parameter data queue to the URL indicated by the action attribute of the submitted form. The value corresponds to each field in the form one by one, which can be seen in the URL. Through HTTP post mechanism, the fields in the form and their contents are placed in the HTML header and sent to the URL address indicated by the action attribute. Users don’t see the process.
  3. The amount of data transferred by get is small and cannot be more than 2KB. The amount of data transferred by post is large, and it is generally set as unlimited by default.
  4. Get security is very low, post security is high. But the efficiency is better than the post method.

52. How to modify the session lifetime

A: first, in China php.ini Set in session.gc_ Maxlifetime = 1440 / / default time

2: Code implementation

$lifetime = 24 * 3600; // save for one day

53. Linux basic command, directory structure

A: the processor architecture of arch display machine (1)

Uname – M shows the processor architecture of the machine (2)

Uname – R shows the kernel version in use

Dmidecode – Q display hardware system components – (SMBIOS / DMI)

Hdparm – I / dev / HDA lists the architectural features of a disk

Hdparm – TT / dev / SDA performs testable read operations on disk

Cat / porc / cpuinfo displays the information of CPU info

Cat / porc / interrupts display interrupts

Cat / porc / meminfo check memory usage

Cat / porc / swap shows which swap is used

Cat / porc / Verion shows the version of the kernel

Cat / porc / net / dev display network adapter and statistics

Cat / porc / mounts displays the loaded file system

Date displays the system date

Cal 2007 shows the calendar for 2007

Date 041217002007.00 set date and time – month, day, hour, year.second

Clock – W saves time changes to BIOS

File search

Find / – name file1 starts from ‘/’ to search the root file system for files and directories

Locate *. PS find files ending in ‘. PS’ – run the’ updatedb ‘command first

Where is halt displays the location of a binary, source, or man

Which halt displays the full path of a binary or executable file

Mount a file system

Mount / dev / hda2 / MNT / hda2 mount a disk called hda2 – make sure the directory ‘/ MNT / hda2’ already exists

Umount / dev / hda2 uninstall a disk called hda2 – first exit from the mount point ‘/ MNT / hda2’

Append command

  1. In Linux, add the content in the file / etc / AAA to the content in / usr / BBB
    sudo cat /etc/aaa >>/usr/bbb
  2. Change / etc/ index.html The owner of the file is Apache, and the file group is Apache
    sudo chmod apache:apache /etc/index.html
  3. Change / etc/ index.html The owner permissions of are read, write and execute. The group permission is read. Other permissions are read
    sudo chmod 744 /etc/index.html
  4. Delete the file named Hello under / etc
    sudo rm /etc/index.html

Of course, if you are performing the above operation as an orot user, you can remove the sudo!

DF – HL view disk free space

DF – H view the partition size of each root path

Du – SH [directory name] returns the size of the directory

Du – SM [folder] returns the total number of m in the folder

Shutdown (system shutdown, restart and logout)

Shutdown – h now

Init 0 shut down the system (2)

Telinit 0 shut down the system (3)

shutdown -h hour:minutes & Shut down the system as scheduled

Shutdown – C cancel the scheduled shutdown of the system

Shutdown – r now restart (1)

Reboot (2)

Logout logout

Files and directories

PWD display working path

Ls view files in directory

LS – f view files in directory

LS – L displays the details of files and directories

LS – a show hidden files

ls[0-9]Displays the file and directory names that contain numbers

Tree shows the tree structure of files and directories starting from the root directory (1)

Lstree shows the tree structure of files and directories starting from the root directory (2)

MKDIR dir1 create a directory called ‘dir1’

disk space

DF – H displays the list of mounted partitions

LS – LSR | more arranges files and directories in size

Du – SH dir1 estimate disk space used by directory ‘dir1’

Download and unzip

1) For. Tar terminated files
  tar -xf all.tar

2) For. GZ terminated files
  gzip -d all.gz
  gunzip all.gz

zip *.jpg

This command is to compress all. JPG files into a zip package


This order is to Extract all the files in

Download command

WGet + space + URL path of the file to download


Shell script

Must start with #! / bin / sh

Simple example: determine whether there is a file in this directory

Num=ls -al /opt |grep "^-"|wc -l
if [ $Num != 0 ]
then echo "/opt has $Num files"
echo "/opt has none file"
Fils - Al / opt | grep "^ -" | WC - L this command can count the number of files. If the number of files is 0, there is no file. If it is not zero, there is a file

54. What data does Memcache cache cache

A: first, the data that is often read and the real-time requirement is not strong can be automatically expired. For example, the latest article list on the home page of the website, the ranking of so and so, and other data.

2、 Data that is often read and requires strong real-time performance. For example, the user’s friends list, user article list, user reading records, etc.

3、 Statistics class cache, such as the number of article views, website PV, etc.

4、 Basic information of active users or a popular article.

5、 Session data

55. Magic method, magic constant

A: 1__ construct()
Is called when the object is instantiated__ When construct and function with class name as function name exist at the same time__ Construct will be called and the other will not be called.

Called when an object is deleted or an object operation is terminated.

Object to call a method. If the method exists, it will be called directly; if it does not exist, it will be called__ Call function.

When reading a property of an object, if the property exists, the value of the property will be returned directly; if it does not exist, the value of the property will be called__ Get function.

When setting a property of an object, if the property exists, it will be assigned directly; if it does not exist, it will be called__ Set function.

Called when the object is cloned. For example: T = newtest(); T1 = clone $t; BJ;

Called when the object is cloned. For example: T = newtest(); T1 = clone $t;

Serialize was called before. If the object is relatively large and you want to delete something and then serialize it, you can consider this function.

Unserialize is called to initialize the object.

Called to detect the existence of an object’s property. For example: isset ($C – > name).

Is called when an object’s properties are unset. For example: unset ($C – > name).

Call var_ When exporting, is called. Use__ set_ The return value of state is var_ The return value of export.

When instantiating an object, if the corresponding class does not exist, the method is called.

Magic constant:

Returns the current line number in the file.

Returns the full path and file name of the file. If used in an include file, the include file name is returned. Since PHP 4.0.2,FILEIt always contains an absolute path, while previous versions sometimes contain a relative path.

Returns the name of the function (added in PHP 4.3.0). Starting from PHP 5, this constant returns the name of the function when it is defined (case sensitive). In PHP 4, the value is always lowercase.

Returns the name of the class (new in PHP 4.3.0). Starting from PHP 5, this constant returns the name of the class when it is defined (case sensitive). In PHP 4, the value is always lowercase.

Returns the method name of the class (added in PHP 5.0.0). Returns the name of the method when it is defined (case sensitive).

6、__ Set() when a program attempts to write a member variable that does not exist or is not visible__ The set () method contains two parameters, which represent the variable name and variable value respectively. Neither parameter can be omitted

7、_ Get () when a program attempts to call an undefined or invisible member variable__ The get () method has a parameter indicating the name of the variable to be called

Wei Sleep () is often used to submit uncommitted data, or similar cleaning operations. If there are some large objects, but not all of them need to be saved, this function is very easy to use.

Wei Construct () executes the function while the class instantiates the object

Wei Struct() is executed when the object instantiated by the class is destroyed

Wei Call() object calls a method. If the method exists, it will be called directly; if it does not exist, it will be called__ Call function.

Wei Clone() is called when cloning an object. For example, $t = new test(); $T1 = clone $t;

Wei Tostring() is called when an object is printed. For example, echo $obj; or print $obj;

Wei Isset () is called when it detects the existence of an object’s property. For example: isset ($C – > name).

Wei Unset () is called to unset the properties of an object. For example: unset ($C – > name).

Wei When autoload() instantiates an object, if the corresponding class does not exist, the method is called.

56. What’s the difference between an interface and an abstract class?

A: an abstract class is a class that cannot be instantiated and can only be used as a parent of other classes. Abstract classes are declared by the keyword abstract.

Abstract class is similar to ordinary class, both contain member variables and member methods. The difference between them is that an abstract class must contain at least one abstract method. An abstract method has no method body, which is naturally rewritten by a subclass.
The format of abstract method is: Abstract Function Abstract method();

The interface is declared by the interface keyword. The member constants and methods in the interface are public. The method can not write the keyword public, and the method in the interface has no method body. Methods in interfaces are inherently implemented by subclasses.

The functions of abstract class and interface implementation are very similar. The biggest difference is that the interface can implement multiple inheritance. In the application, the choice of abstract class or interface depends on the specific implementation.

The subclass inherits, the abstract class uses extensions, and the subclass implementation interface uses implements.

57. What is queue? Exclusive lock, how to solve MyISAM deadlock?

A: by default, MyISAM is a table level lock, so multiple actions of operating a single table at the same time can only be performed in the form of a queue;

Exclusive lock, also known as write lock, is used to exclude other requests during SQL execution, which will be released automatically after execution;

Deadlock resolution: first find the thread number of the deadlock, and then kill the thread ID

58. What are the advantages of bootstrap framework?

A: bootstrap is a web development framework, which consists of CSS, JavaScript and HTML. It is simple and flexible, making web development faster


① Time saving: using bootstrap framework can greatly save project development time. It contains a lot of ready-made code. If you need to use it, you just need to find the right code and insert it in the right place. In addition, CSS is written with less, and many styles and designs have been designed

② Customization: bootstrap can reserve the required parts of the framework according to its own project

③ The design is reasonable

  1. Grid system: bootstrap defines 12 grid system. When the page is finished, you can change the number of lines and layout size according to your own needs according to the appropriate grid. The style has been developed, and you just need to put the code in the appropriate HTML code position
  2. Less: less is a high-level language based on CSS, which aims to make CSS development more flexible and powerful
  3. J avaScript:bootstrap JavaScript library is provided, which goes beyond the basic architecture and style. Developers can easily operate the window, warning box, tool prompt box, etc., which can avoid our painstaking script writing
  4. Consistency: bootstrap can ensure the unity of interface in different platforms, no matter ie, chrome, etc
  5. Continuous update: bootstrap is constantly improving, more regular and continuous
  6. Responsive: the consistency of the interface can be maintained in both PC and mobile terminals
  7. Lots of documents: lots of bootstrap

Pay attention, don’t get lost

OK, everyone, the above is the whole content of this article, you can see the people here, they are allpersonnel。 As I said before, there are many technical points in PHP, but also because there are too many. We can’t write them down, and we won’t see too much when we write them down. So I’ve organized them into PDF and documents here, if necessary

Click to enter the code: blog Garden

More learning content can be accessedAs long as you can read it, your salary will go up a step

The above contents hope to help youA lot of PHPer always encounter some problems and bottlenecks when they are upgrading. They write too much business code and have no sense of direction. They don’t know where to start to improve. For this, I have sorted out some materials, including but not limited to:Distributed architecture, high scalability, high performance, high concurrency, server performance tuning, tp6, laravel, yii2, redis, spool, swoft, Kafka, MySQL optimization, shell script, docker, microservice, nginxAnd so on many knowledge points, advanced dry goods need can be free to share with you, need can join mePHP Technology Exchange Group953224940