PHP 7 Programming Cookbook is a hands-on PHP 7 technical book by the veteran American software developer Doug Bierer, translated into Chinese by Su Baolong. The Chinese edition was published by Publishing House of Electronics Industry in 2017; the original is PHP 7 Programming Cookbook, with simplified Chinese rights granted by Packt Publishing. The book has 13 chapters plus an appendix and is organized as practical recipes in a problem–solution–discussion format, moving by topic from setting up an environment all the way to engineering practice. Chapter 1 covers installation and configuration notes for PHP 7, the built-in web server, a MySQL database for testing, installing PHPUnit and class autoloading, and completes a website scanner and a PHP 5 to PHP 7 code converter. Chapter 2 explains abstract syntax trees, parsing and foreach handling differences, performance enhancements, traversing large files, importing spreadsheets into a database and a recursive directory iterator. Chapters 3 and 4 cover functional programming (type hints, return type declarations, iterators and generators) and object-oriented programming (inheritance, static members, namespaces, visibility, interfaces, traits, anonymous classes). Chapters 5 to 7 focus on database interaction (PDO, an OOP-style SQL builder, pagination, entity mapping, secondary queries, jQuery DataTables queries), a form-element generator and form factory for scalable websites, $_POST filtering and validation, and XML conversion, REST and SOAP clients and servers. Chapters 8 to 10 discuss date/time and internationalization (handling emoji, character conversion, locale detection, number and currency formatting, internationalized calendars and recurring events, non-gettext translation), middleware (validation, access control, caching, routing, cross-framework and cross-language calls) and advanced algorithms (linked lists, bubble sort, stacks, binary search, search engines, multidimensional array aggregation). Chapters 11 to 13 move into engineering: design patterns such as hydrators, the strategy pattern, mappers, object-relational mapping and publish/subscribe; $_POST data filtering and validation, session protection, tokens and CAPTCHAs, a password generator, and encryption/decryption without mcrypt; best practices, exceptions and error handling, unit tests and test suites, mock data generation and custom session parameters. The appendix implements PSR-7 value objects, request classes and response classes in detail.
很多 PHP 7 入门书停留在语法罗列,这本书胜在“配方式”实战:13 章全部围绕可运行的任务展开,从安装环境、PHPUnit 与自动加载起步,一步步写到中间件、PSR-7、加密与单元测试。作者 Doug Bierer 有三十余年开发经验,书中示例既有工具性(网站扫描器、代码转换器、SQL 生成器、表单工厂、数据水合器),也有方法论(策略模式、映射器、发布/订阅、对象关联映射),读者照着做就能把碎片知识串成完整工程能力。第 8 章的国际化日历与循环事件、第 9 章的跨框架跨语言中间件、第 12 章的验证码与不依赖 mcrypt 的加密解密,在同类书中并不常见,对维护老项目、准备迁移到现代 PHP 框架的开发者尤其有参考价值。需要提醒的是,书中部分 API(如 mcrypt 扩展、旧版 PSR 实现路径)在今天已发生变化,阅读时应结合当前 PHP 版本官方文档对照,把重点放在设计思路而非逐字照抄代码上。整体而言,这是一本适合当作“案头工具书+进阶路线图”反复翻查的中高级读物。
The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.