PHP interview best practices in China
English version (third party)
This warehouse mainly summarizes the knowledge points that are often asked in domestic PHP interviews. It only points out knowledge points in a targeted manner, and you need to find relevant information and study systematically by yourself. I hope you can understand not only what it is, but also why and the principles behind it.
If you have very systematic information on the corresponding knowledge points, you are welcome to PR to add links. It is not recommended that you use fork, the information will be updated at any time.
If you are currently in the following situations, this information is very suitable for you:
- I’m planning to change my job, but I don’t know where to start.
- The technology has encountered a bottleneck and I don’t know what to learn.
- Ready to learn PHP, but don’t know how deep the field is?
Basics
- Understand most of the array manipulation functions
- The difference between string processing functions and mb_ series functions
- & Quotes, combined with case analysis
- Difference between == and ===
- The difference between isset and empty
- Understanding all magic functions
- Differences between static, $this, and self
- The difference between private, protected, public and final
- OOP thinking
- Respective usage scenarios of abstract classes and interfaces
- What is Trait?
- Differences between echo, print, and print_r (distinguish the difference between expressions and statements)
- The difference between __construct and __destruct
- static function (distinguishing between classes and functions) manual, SOF
- __toString() function
- The difference between single quotes
'
and double quotes "
- Common HTTP status codes, what do they mean?
- What does 301 mean 404?
Advanced chapter
- Autoload, Composer principle PSR-4, principle
- Session sharing, survival time
- Exception handling
- How to iterate over foreach object
- How to array the operation object
$obj[key];
- How to functionalize object
$obj(123);
- What is yield? Let’s talk about the usage scenario of yield.
- What is PSR, PSR-1, 2, 4, 7
- How to obtain client IP and server IP addresses
- Client IP
- Server IP
- Understand the concept of proxy transparent transmission of actual IP
- How to enable PHP exception prompts
- php.ini turns on
display_errors
and sets error_reporting
level - At runtime, use
ini_set(k, v);
to dynamically set
- How to return a 301 redirect
- [WARNING] Be careful that the script will continue to execute after setting 301. Don't think that the following will not execute. Use
die
or exit
if necessary.
- How to get the extension installation path
-
phpinfo();
Page search extension_dir
- Command line
php -i |grep extension_dir
- Runtime
echo ini_get('extension_dir');
- The principle of comparing strings and numbers. Pay attention to the octal system starting with 0 and the hexadecimal system starting with 0x.
- String comparison size, from left (high bit) to right, character by character ASCII comparison
- What is the BOM header and how to remove it?
-
0xEF
, 0xBB
, 0xBF
- Detect, remove
- What is MVC
- Dependency injection implementation principle
- How to execute a command asynchronously
- What is a template engine, what problems it solves, and its implementation principles (Smarty, Twig, Blade)
- How to implement chain operation
$obj->w()->m()->d();
- Use of Xhprof and Xdebug performance debugging tools
- What is the difference between index array
[1, 2]
and associative array ['k1'=>1, 'k2'=>2]
- How to use cache and scenarios
Practice
- Given a two-dimensional array, sort according to a certain field
- How to determine the uploaded file type, such as: only jpg upload is allowed
- Exchange the values of two variables without using temporary variables
$a=1; $b=2;
=> $a=2; $b=1;
- There are garbled characters in strtoupper when converting Chinese. How do you solve it?
php echo strtoupper('ab你好c');
- Differences between Websocket, Long-Polling, Server-Sent Events(SSE)
- What does the "Headers already sent" error mean and how to avoid it
Algorithm
- Quick sort (handwritten)
- Bubble sort (handwritten)
- Binary search (understanding)
- Find algorithm KMP (understand)
- Depth and breadth first search (understand)
- LRU cache elimination algorithm (understand that Memcached uses this algorithm)
Data structure (understanding)
- Heap and stack characteristics
- queue
- Hash table
- linked list
Comparison
- The difference between Cookie and Session
- The difference between
GET
and POST
- The difference between
include
and require
- The difference between
include_once
and require_once
- The difference between Memcached and Redis
- MySQL storage engines and their differences (you will definitely ask about the difference between MyISAM and Innodb)
- The difference between HTTP and HTTPS
- The difference between Apache and Nginx
- The difference between define() and const
- What are the differences between traits and interfaces and what pain points do traits solve?
- The difference between Git and SVN
Database
- MySQL
- CRUD
- JOIN, LEFT JOIN, RIGHT JOIN, INNER JOIN
- UNION
- GROUP BY + COUNT + WHERE combination case
- Commonly used MySQL functions, such as: now(), md5(), concat(), uuid(), etc.
-
1:1
, 1:n
, n:n
are applicable to each scenario - Understand what a trigger is and describe a usage scenario
- Database optimization methods
- Index, joint index (hit condition)
- Sub-database and sub-table (
水平分表
and垂直分表
) - Partition
- Can use
explain
to analyze SQL performance issues and understand the meaning of each parameter- Focus on understanding
type
, rows
, key
- Slow Log (what is it used for, when is it needed)
- MSSQL (understand)
- Query the latest 5 pieces of data
- NOSQL
- Redis, Memcached, MongoDB
- Comparison and applicable scenarios (comparison can be made from the following dimensions)
- persistence
- Supports multiple data types
- CPU multi-core available
- Memory elimination mechanism
- ClusterCluster
- Support SQL
- Performance comparison
- support matters
- Application scenarios
- What did you use to solve what problem before, and why did you choose it?
Server
- View information such as CPU, memory, time, system version, etc.
- find, grep to find files
- awk processes text
- View the directory where the command is located
- Have you ever compiled PHP yourself? How to turn on the readline function
- How to check the memory and CPU usage of the PHP process
- How to add an extension to PHP
- Modify PHP Session storage location and modify INI configuration parameters
- What are the types of load balancing? Choose one you are familiar with and explain its principles.
- How is the database master-slave replication MS synchronized? Push or pull? Will it be out of sync? what to do
- How to ensure the availability of data so that even if it is deleted, it can be restored to the level of minutes. what will you do.
- There are too many database connections, exceeding the maximum value. How to optimize the architecture. How can it be conveniently processed?
- 502 What is the possible reason? How to troubleshoot 504?
Architecture
- Partial operation and maintenance (understanding):
- Load balancing (Nginx, HAProxy, DNS)
- Master-slave replication (MySQL, Redis)
- Data redundancy and backup (MySQL incremental and full principles)
- Monitoring and inspection (two dimensions of survival and service availability)
- MySQL, Redis, Memcached Proxy, Cluster purpose and principle
- Sharding
- High availability cluster
- RAID
- Source code compilation, memory tuning
- cache
- Whenever you encounter situations where caching is needed at work, briefly describe why.
- Search solutions
- Performance tuning
- Monitoring solutions in various dimensions
- Log collection centralized processing solution
- internationalization
- Database design
- static solution
- Draw common PHP application architecture diagrams
Framework
- ThinkPHP (TP), CodeIgniter (CI), Zend (non-OOP series)
- Yaf, Phalcon (C extension)
- Yii, Laravel, Symfony (pure OOP series)
- Swoole, Workerman (network programming framework)
- The comparison frame distinguishes several direction points
- Is it pure OOP?
- Class library loading method (write your own autoload vs. composer standard)
- Usability direction (CI basic framework, Laravel is a high development efficiency framework and how many basic components are there)
- Black box (compared to C extension system)
- Running speed (eg: Laravel loads a lot of things)
- Memory usage
design pattern
- Singleton pattern (emphasis)
- Factory pattern (key)
- Observer pattern (emphasis)
- Dependency injection (emphasis)
- Decorator pattern
- proxy mode
- Combination mode
Safety
- SQL injection
- XSS and CSRF
- Input filtering
- Cookie security
- Disable
mysql_
functions - When storing user passwords in the database, what should be done to ensure security?
- Verification code Session problem
- Secure Session ID (so that even after interception, it cannot be simulated and used)
- Directory permission security
- Contains local and remote files
- File upload PHP script
-
eval
function executes script -
disable_functions
turns off high-risk functions - FPM independent users and groups, giving specific permissions to each directory
- Understand the difference between Hash and Encrypt
Advanced level
- PHP array underlying implementation (HashTable + Linked list)
- Copy on write principle, when to GC
- PHP process model, process communication method, process thread difference
- What is the core principle of yield?
- PDO prepare principle
- What is the difference between PHP 7 and PHP 5
- Swoole applicable scenarios and coroutine implementation methods
Front-end
- Natively obtain DOM nodes and attributes
- box model
- CSS files, style tags, inline style attribute priority
- HTML and JS running order (page JS from top to bottom)
- JS array operations
- Type judgment
- this scope
- .map() and this specific usage scenario analysis
- Cookie reading and writing
- JQuery operations
- Ajax request (difference between synchronous and asynchronous) random number prohibits caching
- What are the benefits of Bootstrap?
- Cross-domain request N solutions
- New technology (understand)
- ES6
- Modular
- Pack
- Build tools
- vue, react, webpack,
- frontendmvc
- optimization
- Browser concurrent number limit for a single domain name
- Static resource cache 304 (If-Modified-Since and Etag principle)
- Combine multiple small icons and use position positioning technology to reduce requests
- Static resources are combined into a single request and compressed
- CDN
- Static resource delayed loading technology and preloading technology
- keep-alive
- Optimization of CSS at the head and JS at the tail (principle)
Network
- IP address to INT
- What does 192.168.0.1/16 mean?
- What is the main function of DNS?
- The difference between IPv4 and v6
Network Programming
- TCP three-way handshake process
- Differences between TCP and UDP, applicable scenarios respectively
- Is there any way to ensure UDP high availability (understand)
- How to solve TCP sticky packets?
- Why is a heartbeat needed?
- What is a long connection?
- How is HTTPS secure?
- The difference between streams and datagrams
- There are several ways to communicate between processes, which one is the fastest?
- What happens
fork()
?
API chapter
- What is RESTful
- How to make
DELETE
requests compatible with browsers that do not support DELETE
requests - What is the main function of
APP_ID
APP_SECRET
of common APIs? Explain the process - How to ensure that the data in API requests is not tampered with?
- The difference between JSON and JSONP
- The difference between data encryption and signature verification
- What is RSA
- How to deal with API version compatibility
- Current limiting (wooden bucket, token bucket)
- In what scenarios is OAuth 2 mainly used?
- JWT
- What is the difference between
json_encode(['key'=>123]);
and return json_encode([]);
in PHP? What problems will occur? How to solve
Bonus points
- Understand common language features and applicability to different scenarios.
- PHP VS Golang
- PHP VS Python
- PHP VS JAVA
- Learn about PHP extension development
- Proficient in C
statement
This information does not target any company, and we are not responsible for the impact of this information on you. Please be aware.
Good luck
Related references
https://blog.csdn.net/l269798518/article/details/82428601