Home Backend Development PHP Tutorial Intermediate and advanced php interview questions

Intermediate and advanced php interview questions

May 18, 2018 pm 02:16 PM
php test questions

This article mainly introduces intermediate and advanced PHP interview questions, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

Related recommendations: "2019 PHP Summary of interview questions (collection)

1. Give you four coordinate points and judge whether they can form a rectangle, such as judging ([0,0],[0,1],[ 1,1],[1,0]) can form a rectangle.

2. Write a piece of code to determine whether a ring is formed in the one-way linked list. If a ring is formed, please find the entrance of the ring, which is point P

3. Write a function to obtain a All pictures in the article content and download

4. Obtain the IP address of the current client and determine whether it is (111.111.111.111,222.222.222.222)

5. nginx’s log_format configuration As follows:
log_format main 'remoteaddr−remote_user [timelocal]"request"'
'statusbody_bytes_sent "httpreferer"""http_user_agent" "upstreamresponsetime""request_time" "http_x_forwarded_for"';
From today's nginx log file In access.log:

  • a. List the 20 largest rows of "request_time"?

  • b. List the number of visits at 10 a.m. 20 url addresses to buy?

6. What is a CSRF attack? XSS attack? How to prevent it?

7. In applications, we often encounter user The table randomly retrieves 10 pieces of data to display the situation. Briefly describe how you implement this function.

8. Randomly draw 5 cards from the poker cards to determine whether they are a straight, that is, these 5 cards It is continuous

9. How to find the first common node of two intersecting one-way linked lists

10. The longest common subsequence problem LCS. If there are two arrays [1,2,5,11,32,15,77] and [99,32,15,5,1,77], find them To write code with optimal time complexity for numbers that we all have in common, array_intersect cannot be used (there are pitfalls here, and you need to study dynamic programming).

11. Linux memory allocation and multi-threading principles

12. The difference between primary key and unique index in MYSQL

13. The main difference between http and https

14. http status code and its meaning

15. How to check system resource usage in Linux

16. What is the principle of SQL injection? How to prevent SQL injection

17. isset(null) isset(false) empty(null) empty(false) output

18. Methods to optimize MYSQL

19. Database What is the transaction in?

20. Write a function to extract the file extension from a standard URL as efficiently as possible

21. The parameters are arrays of multiple dates and times, and return the one closest to the current time. time

22. The difference between echo, print, and print_r

23. What are the keys and their meanings in the header of the http protocol

24. Code for front, middle and back traversal of the binary tree

25. What are the structural differences between PHP arrays and C language arrays?

26. How to implement Redis's jump table

27. What is hash? How to store data after hash conflict?

28. Clustered index, what is the difference between clustered index?

29. How does B Tree search?

30. What is the difference between array and hash?

31. Write a function to determine whether the following expansion sign is closed. Left and right symmetry means closed: ((())),)(()),(()))), (((((((((()) ()), (()()), ()()

32. Find the unique values ​​in the array [1,2,3,3,2,1,5]

What is your time complexity for questions 33 and 32? In some cases, you write an algorithm, and then the interviewer will ask you to write down the time complexity expression of your algorithm

34. How is this weak type variable implemented in PHP?

35. During HTTP communication, does the client or the server actively disconnect?

36. What are the ways to initiate http requests in PHP? What's the difference?

37. There is a binary tree. Write code to find the shortest path from the root node to the flag node and print it out. There are multiple flag nodes. For example, 6 and 14 in the tree below are flag nodes. Please write code to print the two paths 8, 3, 6 and 8, 10, 14

38. There are two files. The size of the files exceeds 1G. There is one data per line, and each line of data does not exceed 500 bytes. Some of the contents in the two files are exactly the same. Please write code to find the same lines and write them to the new file. The maximum allowed size of PHP is 255M.

39. Please write at least two PHP functions that support callback processing, and implement a PHP function that supports callback.

40. Please write at least two PHP functions that support callback processing.

40. Please write at least two PHP functions that support callback processing. How to download all files (code or ideas).

41. Please write down at least three methods or functions for intercepting file name suffixes (both PHP native functions and self-implemented functions are acceptable)

42. How does PHP implement cookies without its own The function issues cookies to the client. For distributed systems, how to save session values.

###43. Please use SHELL to count the most visited URL addresses in the nginx log within 5 minutes. What are the corresponding IPs? ###

44. Write a shell script to back up the specified mysql library (such as test) to the specified folder and package it, delete the backup 30 days ago, then push the new backup to the remote server, and send an email notification after completion.

45. The difference between innodb and myisam engines in mysql database

46. From the time the user enters the URL in the browser and presses Enter, to seeing the complete meeting, what process does it go through? .

47. How to analyze the performance of a sql statement.

48. When pinging a server fails, which command should be used to trace routing packets?
linux:traceroute,windows:tracert

49、$a=[0,1,2,3]; $b=[1,2,3,4,5]; $a =$ b; What is var_dump($a) equal to?

50. $a=[1,2,3]; foreach($a as &$v){} foreach($a as $v){} var_dump($a) is equal to;

51. The user ID and many deduction rows are stored in the database. The user's wallet is stored in redis. Now we need to write a script to synchronize the deduction records in the database to redis. Execute once every 5 minutes. What issues should be considered?

52. MYSQL master and slave servers. If the master server is the innodb engine and the slave server is the myisam engine, what problems will be encountered in practical applications?

53. What are the process signals in Linux?

54, the underlying implementation of redis

55, asynchronous model

56, 10g file, use php to check its row number

57, there are 1 billion order data, belonging to 1000 drivers, please take out the order amount Top 20 drivers

58, design a WeChat red envelope function

59, count the qps of the last 5 seconds based on the access.log file, and display it in the following format, 01 1000 (the difficulty is 01 Serial number)

60. Why is the performance of php7 improved so much?

61. Traversing a multi-dimensional array

62. There is such a string abcdefgkbcdefab...random length , write a function to find the number of times bcde appears in this string

63. There is a file of 1G size. Each line in it is a word. The size of the word does not exceed 16 bytes. There is a memory limit. The size is 1M. Return the 100 most frequent words

65, PHP process model, how PHP supports multiple concurrency

66, nginx process model, how to support multiple concurrency

67, php-fpm configuration meaning, fpm's daemonize mode
static - the number of child processes is fixed (pm.max_children)
ondemand - the process is only generated when there is a demand (when requested, Contrary to dynamic, pm.start_servers is started when the service starts
dynamic - the number of child processes is set dynamically based on the following configuration: pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers

68. Let you implement a simple architecture and maintain high availability. Two interfaces, one to upload a text and one to obtain the uploaded content. How do you design it? To avoid single computer room failures, and at the same time make the code level insensitive .

69. Two mysql servers, one of which is down, how to make the business end switch without any sense and ensure that the data of the podium server is consistent under normal circumstances

70.http protocol Specific definition

71. What is a lock and how to solve the lock problem

72. The difference between rand and mt_rand

73. How is mysql transaction isolation implemented

74. How to implement mysql lock

75. Symmetric encryption and asymmetric encryption methods

76. 10 bottles of water, one of which is poisonous. After drinking the poisonous water, there will be He died from the poison after 23 hours and 59 minutes. Please use the fewest mice to find this bottle of water within 24 hours.

Related recommendations:

Summary of PHP interview questions


The above is the detailed content of Intermediate and advanced php interview questions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles