📜 ⬆️ ⬇️

PHP Recipes programming. 3rd ed

Good time!
We published the 3rd edition of the book by David Sklyar and Adam Trachtenberg “PHP. Recipes programming "

image

The third edition of this popular book is a collection of ready-made solutions to the most common tasks in the language of PHP. The material interesting for each developer is presented: basic data types, operations with them, cookies, PHP functions, user authentication, work with layers, security problems, program acceleration, networking, graphics creation, error handling, script debugging and writing tests. Recipes are given that affect the basics of object-oriented programming and new PHP functionality. Each recipe is self-sufficient and shows the entire way to solve the problem. The third edition of the book is fully updated under the version of PHP 5.4, and also includes a number of new sections on working with data.

')
Who is this book for?

This book is intended for programmers who want to solve practical problems in PHP. If you don't know anything about PHP yet, use some primer. For readers already familiar with PHP, the book will help you to cope with specific tasks and make your life easier (at least in terms of programming). You will learn how PHP performs operations such as sending email or parsing JSON data, which you may already be able to do in other languages. The book will be a faithful assistant for programmers involved in the processing of applications from other languages ​​in PHP.

What does the book say

No one expects you to sit down and read the book from cover to cover (although if so, we will only be happy!). PHP programmers are constantly faced with a variety of tasks on a wide range of topics. Refer to the book when you have a specific task. Each recipe contains a separate explanation, which will be a good starting point for further work. If the recipe mentions topics that go beyond its scope, then it includes pointers to other recipes, online and offline resources. If you decide to read the whole chapter, that’s fine too. Recipes are usually followed from simple to complex, and at the end of many chapters are examples of programs that link together all the material presented. The introductory part of each chapter provides an overview of the material, including necessary general information, and also mentions recipes of particular interest.

The first four chapters of the book are devoted to the main data types. Chapter 1 deals with such basic operations as substring processing, case-in-case mapping, string splitting, and parsing of data separated by commas. Chapter 2 discusses operations with real numbers, random number generation, conversion of number systems and numeric formatting. Chapter 3 demonstrates working with date and time, their formatting, processing time zones and daylight saving time, as well as determining the time to within milliseconds. Chapter 4 presents operations with arrays: enumerating, merging, inverse rearranging elements, sorting and retrieving individual elements.

Next, there are three chapters in which the main structural elements of the programs are discussed. Chapter 5 discusses such PHP variable options as defaults, static variables, and getting string representations of complex data types. The recipes in Chapter 6 relate to the use of functions in PHP: processing arguments, passing and returning variables by reference, creating functions at runtime and the scope of variables. Chapter 7 discusses the object-oriented features of PHP, from the simplest to such non-trivial features as special methods, destructors, access control, reflection, types, and namespaces.

Following the data types and structural elements of the programs are six chapters with topics that are central to web programming. Chapter 8 covers cookies, headers, authentication, query string handling, and other key web application features. Chapter 9 is devoted to processing and validating data entered on forms, displaying multi-page forms, displaying forms with error messages, and protecting against potential hazards such as cross-site scripting attacks and resubmitting forms. Chapter 10 explains the differences between the SQL and DBM databases, and using the example of the abstraction level of access to the PDO databases, shows how to connect to the database, assign unique identifier values, read lines, change data, escape special characters, and save debug information in the log. Chapter 11 discusses the PHP built-in session module, which allows you to save user information as you move from page to page. This chapter also describes some security issues encountered when working with session data. The main topic of chapter 12 is XML markup language: the SimpleXML extension and DOM functions, the use of XPath and XSLT, the reading and writing of RSS and Atom feeds. Chapter 13 covers topics that are useful for PHP applications that are integrated with external sites and client-side JavaScript code: addressing URLs, clearing HTML markup, and responding to Ajax requests.

The next three chapters are network interactions. Chapter 14 discusses the nuances of using web services (for example, external REST-compatible services) from your code. In Chapter 15, you will have a look at the work of web services from the reverse side - the discussion will deal with the organization of processing REST requests. Both chapters discuss authentication, heading, and error handling. Chapter 16 discusses other network services: sending emails, using LDAP, and resolving DNS.

The next part of the book contains several chapters on the features and extensions of PHP, helping to build powerful, secure, convenient, and efficient applications. Chapter 17 shows how to create graphic images; its recipes deal with the output of text, lines, polygons and curves. Chapter 18 focuses on security issues: preventing session fixation and cross-site scripting attacks, working with passwords and data encryption. Chapter 19 tells you how to make your application convenient for users from other countries; it also contains recipes for localizing text, date and time, monetary amounts and graphics, as well as working with text in UTF-8 encoding. Chapter 20 discusses error handling and logging in detail, while Chapter 21 discusses debugging tools, writing tests, and using the PHP embedded web server. Chapter 22 explains how to compare the speed of two functions and get programs running at maximum speed. Chapter 23 deals with regular expressions, saving text from HTML tags, calling PHP functions from regular expressions, using maximum and minimum search.

Chapters 24 and 25 are devoted to the file system. Chapter 24 is limited to file operations: opening and closing, using temporary files, setting locks, transferring compressed files, processing file contents. Chapter 25 deals with directories and file metadata, and its recipes deal with changing permissions and ownership, moving and deleting files, handling all files in a directory.

Finally, the last two chapters cover topics that go beyond the capabilities of PHP. In chapter 26, you will learn what can be done with PHP outside of web programming. These recipes deal with topics related to command line mode, such as parsing program arguments and reading passwords. Chapter 27 introduces the Composer, PEAR (PHP Extension and Application Repository) and PECL (PHP Extension Community Library) repositories. Composer and PEAR provide access to PHP code that provides functions and extensions for PHP. PECL also contains a selection of PHP extensions, but written in C. PEAR and PECL modules are used repeatedly in the book, and Chapter 27 describes the process for installing and updating them.

About the authors

David Sklar is an independent technology consultant. In addition to the book "PHP Cookbook", he is also the author of the books "Learning PHP 5" (O'Reilly), "Essential PHP Tools" (Apress) and a brilliant blog. David lives in New York and holds a degree in computer science from Yale University.

Adam Trachtenberg is the head of the LinkedIn Developer Network, the author of the books “Upgrading to PHP 5” and “PHP Cookbook” (O'Reilly). Previously, he worked as a manager in the field of platforms and services for eBay. Adam lives in Mountain View (California) and holds a bachelor’s degree in mathematics and a master’s degree in business administration from Columbia University.

More information about the book can be found on the publisher's website.
Table of contents
Excerpt

For Habrozhiteley there is a 25% discount on the coupon - PHP

Book on this topic:
PHP and MySQL. A comprehensive guide. 2nd ed.
Author: B. McLaughlin

Source: https://habr.com/ru/post/255145/


All Articles