{"id":15108567,"url":"https://github.com/wudi/php-interview-best-practices-in-china","last_synced_at":"2025-09-27T07:31:38.336Z","repository":{"id":68182734,"uuid":"140526191","full_name":"wudi/PHP-Interview-Best-Practices-in-China","owner":"wudi","description":"📙 PHP 面试知识点汇总","archived":true,"fork":false,"pushed_at":"2018-10-09T01:05:55.000Z","size":39,"stargazers_count":1181,"open_issues_count":0,"forks_count":221,"subscribers_count":70,"default_branch":"master","last_synced_at":"2024-10-29T11:11:50.990Z","etag":null,"topics":["interview","interview-questions","mian-shi","php","question-answering"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wudi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-11T05:33:06.000Z","updated_at":"2024-10-17T03:23:05.000Z","dependencies_parsed_at":"2023-02-26T19:00:43.908Z","dependency_job_id":null,"html_url":"https://github.com/wudi/PHP-Interview-Best-Practices-in-China","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wudi%2FPHP-Interview-Best-Practices-in-China","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wudi%2FPHP-Interview-Best-Practices-in-China/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wudi%2FPHP-Interview-Best-Practices-in-China/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wudi%2FPHP-Interview-Best-Practices-in-China/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wudi","download_url":"https://codeload.github.com/wudi/PHP-Interview-Best-Practices-in-China/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234410138,"owners_count":18828150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interview","interview-questions","mian-shi","php","question-answering"],"created_at":"2024-09-25T22:04:11.478Z","updated_at":"2025-09-27T07:31:33.060Z","avatar_url":"https://github.com/wudi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP interview best practices in China\n\n[English version](http://www.codeblogbt.com/archives/428096) (third party)\n\n\u003e 该仓库主要真是国内 PHP 面试经常被问到的知识点做汇总。\n\u003e 仅是针对性指出知识点，相应还需自己查找相关资料系统学习。\n\u003e 我希望各位能不仅仅了解是什么，还要了解为什么，以及背后的原理。\n\n\u003e 如果您有对相应知识点非常系统的资料，欢迎 PR 增加链接。\n\u003e 不建议您使用 fork，资料会随时更新。\n\n如果你现在处于以下几种状态，本资料非常适合你：\n\n* 准备换工作，不知道从哪开始准备\n* 技术遇到瓶颈，不知道该学什么\n* 准备学 PHP，但不知道领域有多深\n\n## 基础篇\n* [了解大部分数组处理函数](http://php.net/manual/zh/ref.array.php)\n* [字符串处理函数](http://php.net/manual/zh/ref.strings.php)  [区别 mb_ 系列函数](http://php.net/manual/zh/book.mbstring.php)\n* [\u0026 引用，结合案例分析](https://secure.php.net/manual/zh/language.references.php)\n* [== 与 === 区别](https://stackoverflow.com/questions/80646/how-do-the-php-equality-double-equals-and-identity-triple-equals-comp)\n* [isset 与 empty 区别](https://stackoverflow.com/questions/1219542/in-where-shall-i-use-isset-and-empty)\n* [全部魔术函数理解](http://php.net/manual/zh/language.oop5.magic.php)\n* [static、$this、self 区别](https://stackoverflow.com/questions/4718808/php-can-static-replace-self)\n* private、protected、public、final 区别\n* OOP 思想\n* 抽象类、接口 分别使用场景\n* [Trait 是什么东西](http://php.net/manual/zh/language.oop5.traits.php)\n* [echo、print、print_r 区别(区分出表达式与语句的区别)](https://stackoverflow.com/questions/1647322/whats-the-difference-between-echo-print-and-print-r-in-php)\n* [__construct 与 __destruct 区别](http://php.net/manual/zh/language.oop5.decon.php)\n* static 作用（区分类与函数内）[手册](http://php.net/manual/zh/language.oop5.static.php) 、[SOF](https://stackoverflow.com/questions/7508284/static-variables-in-php)\n* [__toString() 作用](http://php.net/manual/en/language.oop5.magic.php#object.tostring)\n* [单引号`'`与双引号`\"`区别](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php#answer-3446286)\n* [常见 HTTP 状态码，分别代表什么含义](https://zh.wikipedia.org/wiki/HTTP%E7%8A%B6%E6%80%81%E7%A0%81)\n* [301](https://zh.wikipedia.org/wiki/HTTP_301) 什么意思 [404](https://zh.wikipedia.org/wiki/HTTP_404) 呢?\n\n## 进阶篇\n* Autoload、Composer 原理 [PSR-4](https://laravel-china.org/topics/2081/psr-specification-psr-4-automatic-loading-specification) 、[原理](https://segmentfault.com/a/1190000014948542)\n* Session 共享、存活时间\n* 异常处理\n* [如何 foreach 迭代对象](https://secure.php.net/manual/zh/class.iterator.php)\n* [如何数组化操作对象 `$obj[key];`](https://secure.php.net/manual/zh/class.arrayaccess.php)\n* [如何函数化对象 `$obj(123);`](http://php.net/manual/en/language.oop5.magic.php#object.invoke)\n* yield 是什么，说个使用场景 [yield](https://www.oschina.net/translate/cooperative-multitasking-using-coroutines-in-php)\n* [PSR 是什么，PSR-1, 2, 4, 7](http://psr.phphub.org/)\n* 如何获取客户端 IP 和服务端 IP 地址\n    * [客户端 IP](https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php)    \n    * [服务端 IP](https://stackoverflow.com/questions/5800927/how-to-identify-server-ip-address-in-php)\n    * 了解代理透传 实际IP 的概念\n* 如何开启 PHP 异常提示\n    * php.ini 开启 `display_errors` 设置 `error_reporting` 等级\n    * 运行时，使用 `ini_set(k, v);` 动态设置\n* [如何返回一个301重定向](https://stackoverflow.com/questions/7324645/php-header-redirect-301-what-are-the-implications) \n    * **[WARNING]** 一定当心设置 301 后脚本会继续执行，不要认为下面不会执行，必要时使用 `die` or `exit`\n* 如何获取扩展安装路径\n    * `phpinfo();` 页面查找 `extension_dir`\n    * 命令行 `php -i |grep extension_dir`\n    * 运行时 `echo ini_get('extension_dir');`\n* 字符串、数字比较大小的原理，注意 0 开头的8进制、0x 开头16进制\n    * 字符串比较大小，从左(高位)至右，逐个字符 ASCII 比较\n* BOM 头是什么，怎么除去\n    * `0xEF`,`0xBB`,`0xBF`\n    * [检测、去除](https://stackoverflow.com/questions/10290849/how-to-remove-multiple-utf-8-bom-sequences-before-doctype)\n* 什么是 MVC \n* 依赖注入实现原理\n* 如何异步执行命令\n* 模板引擎是什么，解决什么问题、实现原理（Smarty、Twig、Blade）\n* 如何实现链式操作 `$obj-\u003ew()-\u003em()-\u003ed();`\n* Xhprof 、Xdebug 性能调试工具使用\n* 索引数组 `[1, 2]` 与关联数组 `['k1'=\u003e1, 'k2'=\u003e2]` 有什么区别\n* [缓存的使用方式、场景](https://zhuanlan.zhihu.com/p/40091810)\n\n## 实践篇\n* 给定二维数组，根据某个字段排序\n* 如何判断上传文件类型，如：仅允许 jpg 上传\n* 不使用临时变量交换两个变量的值 `$a=1; $b=2;`  =\u003e  `$a=2; $b=1;`\n* strtoupper 在转换中文时存在乱码，你如何解决？```php echo strtoupper('ab你好c'); ```\n* Websocket、Long-Polling、Server-Sent Events(SSE) 区别\n* \"Headers already sent\" 错误是什么意思，如何避免\n\n## 算法篇\n* 快速排序（手写）\n* 冒泡排序（手写）\n* 二分查找（了解）\n* 查找算法 KMP（了解）\n* 深度、广度优先搜索（了解）\n* LRU 缓存淘汰算法（了解，Memcached 采用该算法）\n\n## 数据结构篇（了解）\n* 堆、栈特性\n* 队列\n* 哈希表\n* 链表\n\n## 对比篇\n* Cookie 与 Session 区别\n* `GET` 与 `POST` 区别\n* `include` 与 `require` 区别\n* `include_once` 与 `require_once` 区别\n* Memcached 与 Redis 区别\n* MySQL 各个存储引擎、及区别（一定会问 MyISAM 与 Innodb 区别）\n* HTTP 与 HTTPS 区别\n* Apache 与 Nginx 区别\n* define() 与 const 区别\n* traits 与 interfaces 区别 及 traits 解决了什么痛点？\n* Git 与 SVN 区别\n\n## 数据库篇\n* MySQL\n    * CRUD\n    * JOIN、LEFT JOIN 、RIGHT JOIN、INNER JOIN\n    * UNION\n    * GROUP BY + COUNT + WHERE 组合案例\n    * [常用 MySQL 函数，如：now()、md5()、concat()、uuid()等](https://www.w3schools.com/sql/sql_ref_mysql.asp)\n    * `1:1`、`1:n`、`n:n` 各自适用场景\n    * 了解触发器是什么，说个使用场景\n    * 数据库优化手段\n        * 索引、联合索引（命中条件）\n        * 分库分表（`水平分表`、`垂直分表`）\n        * 分区\n        * 会使用 `explain` 分析 SQL 性能问题，了解各参数含义\n            * 重点理解 `type`、`rows`、`key`\n        * Slow Log（有什么用，什么时候需要）\n* MSSQL(了解)\n    * 查询最新5条数据\n* NOSQL\n    * Redis、Memcached、MongoDB\n    * 对比、适用场景（可从以下维度进行对比）\n        * 持久化\n        * 支持多钟数据类型\n        * 可利用 CPU 多核心\n        * 内存淘汰机制\n        * 集群 Cluster\n        * 支持 SQL\n        * 性能对比\n        * 支持事务\n        * 应用场景\n    * 你之前为了解决什么问题使用的什么，为什么选它？\n\n## 服务器篇\n* 查看 CPU、内存、时间、系统版本等信息\n* find 、grep 查找文件\n* awk 处理文本\n* 查看命令所在目录\n* 自己编译过 PHP 吗？如何打开 readline 功能\n* 如何查看 PHP 进程的内存、CPU 占用\n* 如何给 PHP 增加一个扩展\n* 修改 PHP Session 存储位置、修改 INI 配置参数\n* 负载均衡有哪几种，挑一种你熟悉的说明其原理\n* 数据库主从复制 M-S 是怎么同步的？是推还是拉？会不会不同步？怎么办\n* 如何保障数据的可用性，即使被删库了也能恢复到分钟级别。你会怎么做。\n* 数据库连接过多，超过最大值，如何优化架构。从哪些方便处理？\n* 502 大概什么什么原因？ 如何排查  504呢？\n\n## 架构篇\n* 偏运维（了解）：\n    * 负载均衡（Nginx、HAProxy、DNS）\n    * 主从复制（MySQL、Redis）\n    * 数据冗余、备份（MySQL增量、全量 原理）\n    * 监控检查（分存活、服务可用两个维度）\n    * MySQL、Redis、Memcached Proxy 、Cluster 目的、原理\n    * 分片\n    * 高可用集群\n    * RAID\n    * 源代码编译、内存调优\n* 缓存\n    * 工作中遇到哪里需要缓存，分别简述为什么\n* 搜索解决方案\n* 性能调优\n* 各维度监控方案\n* 日志收集集中处理方案\n* 国际化\n* 数据库设计\n* 静态化方案\n* 画出常见 PHP 应用架构图\n\n## 框架篇\n* ThinkPHP（TP）、CodeIgniter（CI）、Zend（非 OOP 系列）\n* Yaf、Phalcon（C 扩展系）\n* Yii、Laravel、Symfony（纯 OOP 系列）\n* Swoole、Workerman （网络编程框架）\n* 对比框架区别几个方向点\n    * 是否纯 OOP\n    * 类库加载方式（自己写 autoload 对比 composer 标准）\n    * 易用性方向（CI 基础框架，Laravel 这种就是高开发效率框架以及基础组件多少） \n    * 黑盒（相比 C 扩展系）\n    * 运行速度（如：Laravel 加载一大堆东西）\n    * 内存占用\n\n## 设计模式\n* 单例模式（重点）\n* 工厂模式（重点）\n* 观察者模式（重点）\n* 依赖注入（重点）\n* 装饰器模式\n* 代理模式\n* 组合模式\n\n## 安全篇\n* SQL 注入\n* XSS 与 CSRF\n* 输入过滤\n* Cookie 安全\n* 禁用 `mysql_` 系函数\n* 数据库存储用户密码时，应该是怎么做才安全\n* 验证码 Session 问题\n* 安全的 Session ID （让即使拦截后，也无法模拟使用）\n* 目录权限安全\n* 包含本地与远程文件\n* 文件上传 PHP 脚本\n* `eval` 函数执行脚本\n* `disable_functions` 关闭高危函数\n* FPM 独立用户与组，给每个目录特定权限\n* 了解 Hash 与 Encrypt 区别\n\n## 高阶篇\n* PHP 数组底层实现 （HashTable + Linked list）\n* Copy on write 原理，何时 GC\n* PHP 进程模型，进程通讯方式，进程线程区别\n* yield 核心原理是什么\n* PDO prepare 原理\n* PHP 7 与 PHP 5 有什么区别\n* Swoole 适用场景，协程实现方式\n\n## 前端篇\n* 原生获取 DOM 节点，属性\n* 盒子模型\n* CSS 文件、style 标签、行内 style 属性优先级\n* HTML 与 JS 运行顺序（页面 JS 从上到下）\n* JS 数组操作\n* 类型判断\n* this 作用域\n* .map() 与 this 具体使用场景分析\n* Cookie 读写\n* JQuery 操作\n* Ajax 请求（同步、异步区别）随机数禁止缓存\n* Bootstrap 有什么好处\n* 跨域请求 N 种解决方案\n* 新技术（了解）\n    * ES6\n    * 模块化\n    * 打包\n    * 构建工具\n    * vue、react、webpack、\n    * 前端 mvc \n* 优化\n    * 浏览器单域名并发数限制\n    * 静态资源缓存 304 （If-Modified-Since 以及 Etag 原理）\n    * 多个小图标合并使用 position 定位技术 减少请求\n    * 静态资源合为单次请求 并压缩\n    * CDN\n    * 静态资源延迟加载技术、预加载技术\n    * keep-alive\n    * CSS 在头部，JS 在尾部的优化（原理）\n\n\n## 网络篇\n\n* IP 地址转 INT\n* 192.168.0.1/16 是什么意思\n* DNS 主要作用是什么？\n* IPv4 与 v6 区别\n\n## 网络编程篇\n\n* TCP 三次握手流程\n* TCP、UDP 区别，分别适用场景\n* 有什么办法能保证 UDP 高可用性(了解)\n* TCP 粘包如何解决？\n* 为什么需要心跳？\n* 什么是长连接？\n* HTTPS 是怎么保证安全的？\n* 流与数据报的区别\n* 进程间通信几种方式，最快的是哪种？\n* `fork()` 会发生什么？\n\n## API 篇\n\n* RESTful 是什么\n* 如何在不支持 `DELETE` 请求的浏览器上兼容 `DELETE` 请求\n* 常见 API 的 `APP_ID` `APP_SECRET` 主要作用是什么？阐述下流程 \n* API 请求如何保证数据不被篡改？\n* JSON 和 JSONP 的区别\n* 数据加密和验签的区别\n* RSA 是什么\n* API 版本兼容怎么处理\n* 限流（木桶、令牌桶）\n* OAuth 2 主要用在哪些场景下\n* JWT\n* PHP 中 `json_encode(['key'=\u003e123]);` 与 `return json_encode([]);` 区别，会产生什么问题？如何解决\n\n## 加分项\n* 了解常用语言特性，及不同场景适用性。\n   * PHP VS Golang\n   * PHP VS Python\n   * PHP VS JAVA\n* 了解 PHP 扩展开发\n* 熟练掌握 C\n\n\n## 声明\n\n该资料不针对任何一家公司，对因该资料对您产生的影响概不负责，望知晓。\n\n祝顺利\n\n## 相关参考\n\nhttps://blog.csdn.net/l269798518/article/details/82428601\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwudi%2Fphp-interview-best-practices-in-china","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwudi%2Fphp-interview-best-practices-in-china","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwudi%2Fphp-interview-best-practices-in-china/lists"}