Key PHP Interview Topics: HTTP Status Codes, Pass‑by‑Value/Reference, Design Patterns, XSS, CGI/FastCGI/PHP‑FPM, MVC, Garbage Collection, CLI Lifecycle, Memory Management, Arrays, Dependency Injection, OOP

This article summarizes essential PHP interview knowledge, covering HTTP status codes, value vs. reference passing, major design patterns, XSS mitigation, the CGI/FastCGI/PHP‑FPM architecture, MVC, garbage collection, CLI lifecycle, memory allocation, array implementation, dependency injection, and core object‑oriented principles.

php Courses
php Courses
php Courses
Key PHP Interview Topics: HTTP Status Codes, Pass‑by‑Value/Reference, Design Patterns, XSS, CGI/FastCGI/PHP‑FPM, MVC, Garbage Collection, CLI Lifecycle, Memory Management, Arrays, Dependency Injection, OOP

1. HTTP status codes : 302 temporary redirect, 401 unauthorized, 403 forbidden, 500 internal server error.

2. Pass‑by‑value vs. pass‑by‑reference : value copies the argument, reference passes the variable’s address, so modifications affect the original.

3. Design patterns :

Creational: Prototype, Factory, Singleton, Builder, Abstract Factory.

Structural: Adapter, Bridge, Flyweight, Facade, Proxy, Composite, Decorator.

Behavioral: Memento, Chain of Responsibility, Command, Iterator, Mediator, State, Template Method, Visitor, Observer, Strategy.

4. Code management : Teams commit code to a version‑control server; a project lead manages versions to enable rollback and improve development efficiency.

5. XSS attacks : Attackers inject malicious scripts into web pages; mitigation is done by applying htmlspecialchars() to user input.

6. CGI, FastCGI, PHP‑FPM relationship :

Web Server (e.g., Apache, Nginx) serves static files directly.

For a PHP request, the server launches a CGI program (the PHP interpreter) which reads php.ini, processes the script, and returns the result via the CGI protocol.

Definitions: Web Server, Web Application, CGI, FastCGI, PHP‑CGI, PHP‑FPM.

7. MVC architecture : Model handles data operations, View renders the UI, Controller contains business logic.

8. PHP garbage collection : Uses reference counting; an object is freed when its reference count drops to zero.

9. CLI lifecycle stages :

Stage

Function

Purpose

Module initialization

php_module_startup()

Initialize PHP core and Zend engine.

Request initialization

php_request_startup()

Prepare request data for FPM workers.

Script execution

php_execute_script()

Parse PHP code and generate an abstract syntax tree.

Request shutdown

php_request_shutdown()

Execute cleanup at the end of a request.

Module shutdown

php_module_shutdown()

Run when the process terminates.

10. PHP‑FPM operation : FastCGI is the protocol between web server and PHP; PHP‑FPM implements FastCGI with a master‑worker model. Process management modes include static (fixed workers), dynamic (adjusts workers based on load), and ondemand (spawns workers on demand). The master runs an event loop handling I/O and timers.

11. Memory allocation : PHP pre‑allocates a memory pool to reduce OS‑level allocation overhead for small requests.

12. PHP array implementation : Implemented as a hash table (hash map) providing average O(1) lookup time.

13. Dependency injection : Services receive their dependencies from the outside (often via reflection), reducing coupling and allowing code to depend on interfaces rather than concrete implementations.

14. Object‑oriented programming : Emphasizes encapsulation, inheritance, polymorphism, and follows SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion).

Related article: “PHP interview questions – application problems collection”.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendperformancearchitecturePHPweb-developmentdesign-patterns
php Courses
Written by

php Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.