Home > headlines > 2019 Spring Recruitment PHP Interview Questions (with Answers)

2019 Spring Recruitment PHP Interview Questions (with Answers)

幸せな気
Release: 2019-09-17 16:56:24
forward
12638 people have browsed it

This interview not only hopes to start a new journey and understand the world, but also a process of discovering one's own shortcomings, and an opportunity to determine the direction of future development (learning). (Attached: Mind map of interview knowledge points)

Related recommendations: "2019 PHP Interview Questions Summary (Collection)"

PHP

#php is the best language in the world! No rebuttal accepted!

1. Basics

1. The difference between session and cookie
Session is a data structure saved on the server and used to track users status, this data can be saved in clusters, databases, and files

Cookie is a mechanism for the client to save user information. It is used to record some user information and is also used to implement Session. a method.

2, Have you used PHP7 and learn about the new features

PHP7 has achieved leapfrog improvements in performance, new operators, unified variable syntax, etc.

3 , Magic variable

asked about the meaning of __dir__, this is the directory where the answer file is located

4, Magic method

This is a question that is often asked I remember the commonly used ones, but I was confused when I suddenly asked about __invoke()
__construct(), __destruct(), __call(), __callStatic() , __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone() and __debugInfo()

2. Data structures and algorithms

1, Stack data structure

As long as the popping data structure can be implemented using code

2, Bubble sort

As long as bubble sorting can be implemented using code

3. The difference between a complete binary tree and a full binary tree

Only the node degrees of the bottom two levels can be less than 2, and the nodes of the bottom level are concentrated on the leftmost side of the level. A binary tree at certain positions is a complete binary tree
And a binary tree with a depth of h and 2^h-1 nodes is Full binary tree

3. Architecture related

1. What is the difference between Laravel and ThinkPHP? What do you want to complain about laravel

I started with routing, Different levels from middleware to controllers, data access, views, etc. are introduced
If you want to complain, laravel may be a bit 'heavy' compared to some projects

2, Have you ever released your own package with composer? ( PHP modular development based on Composer)

I answered no, I just learned about it
The interviewer said that their framework is their own A secondary development framework based on Discuz. Based on its excellent foundation, composer dependency management is also introduced into blabla

3. Let’s talk about the understanding of MVC

combined with project description templates and views , the relationship between controllers and the basic composition

4. Protection

1. XSS cross-site scripting attack
2. DDOS traffic attack
3, CSRF Cross-site request forgery attack
4, SQL injection

Control or limit user input in the front-end form
Filter when there are back-end parameters and data to be passed, etc.

5. Project

1, How to solve the concurrency problem in the project

My solution is to first control the valid requests on the front end, for example, only one normal request per minute
Then The backend also filters invalid requests, and then puts the operations into the queue to implement

An interviewer asked, is your queue blocked? If two users really purchase at the same time, two users will wait. Completed, they still use the same thread to complete, have you considered using other ways to achieve
I said no, he said yes Using the lock mechanism, the second one waits for the first one to complete, one after another

2, WeChat payment specific implementation process

1. The H5 page initiates a payment request and requests to generate a payment order
2. Call the unified order API to generate a prepaid order
3. Generate payment parameters called by JSAPI page and sign
4. WeChat browser automatically activates payment JSAPI interface payment
5. Confirm payment
6. Asynchronous communication Notify the merchant of the payment result, and the merchant will receive the notification and return the confirmation message
7. Return the payment result and display Display payment information to the user

3, simply implement the login and registration function

Each framework considers different aspects, so just write the corresponding code according to your own understanding
4, How to design a mall

I first limited myself to a B2C mall, then started with the data table, and then simply Introducing the front-end and back-end implementation logic

MYSQL

Mysql optimization is basically a top priority, especially testing technology
1. Basics

1, what is the difference between InnoDB and MyISAM

Provided by InnoDB Transaction processing, row-level locks, supports foreign keys, and supports multiple row formats
MyISAM only supports table-level locks, full-text indexes, and heap tables

2, What are the characteristics of transactions

Atomicity, consistency, isolation, durability
3, Transaction isolation level

Uncommitted read, committed read, repeatable read, serializable

4 , there is a table field of O_Id, OrderDate, OrderPrice, and Customer. We want to find the order total. Customers whose amount is less than 2000

    SELECT Customer,SUM(OrderPrice) FROM 

Orders

    GROUP BY Customer

    HAVING SUM(OrderPrice)<2000
Copy after login

5, query the data of the student table, those who are greater than 60 are passed, otherwise they are failed

select score, category=Case
WHEN score >=60 THEN 'Pass'
ELSE 'Fail '
END
from grade list

6, query the student number and name of students who have not completed all courses

    SELECT a.SNO ,a.SNAME  

    FROM student a  

    WHERE a.`SNO` NOT IN  

        ( SELECT b.`SNO` FROM SC b  

        GROUP BY b.`SNO` HAVING COUNT(*) =  

            ( SELECT COUNT(*)  FROM course)

        );
Copy after login

2. Optimization

1, "select * from student where name='red'","select * from student where name='blue'", optimize statement

    select name from student where 

name=&#39;red&#39;
    union
    select 

name from student where name=&#39;blue&#39;
Copy after login

If you use the or condition, the myisam table can use the index, but innodb cannot.
innodb replaces OR with UNION (applicable to index columns)

2, how do you generally optimize the database

Query cache, EXPLAIN, (joint) index, use fixed length Static table

Server

##1. Protection

How to protect the server

Only open limited ports, restrict login IPs, restrict login accounts

It is also a question that can be ordered into a book, and can be answered according to the project

2. Protocol

What is the difference between Get and Post

The parameters of Get are included in the URL. The GET request will be actively cached by the browser and is URL encoded. There is a character limit for parameters to be ASCII characters

Post passes parameters through the request body, and There are multiple encoding methods

3. NginX

How to process php script requests when setting nginx

The default configuration is to forward to FastCGI for processing


4. Redis

1. What data do you use redis to cache?

According to the project, some of the data you cache often need to be cached. Data used

2. How to achieve persistence in Redis and what refresh frequency to configure

Configure aof persistence and refresh the aof file every second by default

3. Is Redis multithreaded? The official cluster plan has not been implemented in practice. It may take several weeks to implement. Complete

5. Code Management

Have you ever used git? When two people submit the wrong code, how to solve it

I have used git to submit the code. If this happens, you can git pull the remote code to the local one first. , then modify the conflicting code or Git tag content correctly, and then resubmit the code

    

Others

1. Why you left your job Answered wittyly, mentioning a little bit about the company or your own affairsYou have less money and more work, but far away

2. Your ideal team

Passionate about technology, actively solve problems, and work together

3. Career planning

Front-end in-depth, back-end in-depth, data optimization analysis and collection, server penetrationblabla

4. Questions I want to ask

Generally, they will ask what projects the company has, its technical structure, whether it is profitable, etc.

Different companies have different technology stacks and different concerns. Sometimes they will ask about the specific solution to the problem of blocking. , some pay more attention to project efficiency, and some also pay attention to server construction, whether they have built their own frameworks and their understanding of popular frameworks. , you may be able to find the development direction you want in the process

Postscript

I got 7 offers from 9 companies in 5 days, which feels pretty good. During the interview, most companies will ask detailed questions based on the items on the resume. Interview At the same time, you can see the breadth of technology (how many projects or skills you have experienced), and the depth of technology (data optimization, framework understanding and production, service Server attack and defense penetration), I hope everyone can continue to practice and learn the technology as the project develops. \(•ㅂ•)/♥ encourage each other ~

Attached: Mind map of interview knowledge points

2019 Spring Recruitment PHP Interview Questions (with Answers)

Related labels:
source:超全栈
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template