Back to Home

PHP Recipes for programming. 3rd ed / Blog of the company Publishing House "Peter"

php

PHP Recipes for programming. 3rd ed

    Good time!
    We have released the 3rd edition of the book by David Sklyar and Adam Trachtenberg, “PHP. Programming Recipes

    image

    The third edition of this popular book is a selection of ready-made solutions to the most common tasks in the PHP language. The material is interesting for each developer: basic data types, operations with them, cookies, PHP functions, user authentication, working with layers, security problems, speeding up programs, working on the network, creating graphic images, error handling, script debugging and writing tests. Recipes are given that cover the basics of object-oriented programming and the new PHP functionality. Each recipe is self-sufficient and shows the whole way to solve the problem. The third edition of the book is fully updated for 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 tutorial for beginners. For readers already familiar with PHP, the book will help you to cope with specific tasks and simplify your life (at least with regard to programming). You’ll learn how PHP performs operations such as sending emails or parsing JSON data — which you may already be able to perform in other languages. The book will be a loyal assistant for programmers involved in processing applications from other languages ​​in PHP.

    What the book says

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

    The first four chapters of the book are devoted to the main data types. Chapter 1 covers basic operations such as processing substrings, character case conversions, linebreaking, and parsing data separated by commas. Chapter 2 discusses operations with real numbers, generating random numbers, converting number systems and number formatting. Chapter 3 shows how to work with date and time, how to format them, how to process time zones and daylight saving time, and how to determine time to the nearest millisecond. Chapter 4 presents operations with arrays: enumeration, merging, reverse permutation of elements, sorting and extraction of individual elements.

    Next are three chapters that discuss the basic structural elements of programs. Chapter 5 discusses the possibilities of working with PHP variables such as default values, static variables, and obtaining string representations of complex data types. The recipes in chapter 6 relate to the use of functions in PHP: handling 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 simple to non-trivial features like special methods, destructors, access control, reflection, traits and namespaces.

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

    The next three chapters are devoted to networking. Chapter 14 discusses the nuances of using web services (using external REST compatible services as an example) from your code. In chapter 15, you have to look at the work of web services from the reverse side - we will talk about organizing the processing of REST requests. Both chapters discuss authentication, heading, and error handling. Chapter 16 discusses other network services: sending emails, using LDAP, and DNS resolution.

    The next part of the book contains several chapters devoted to the possibilities and extensions of PHP, contributing to the construction of powerful, safe, convenient and efficient applications. Chapter 17 shows how to create graphic images; her recipes examine the output of text, lines, polygons, and curves. Chapter 18 focuses on security issues: preventing session fixation and cross-site scenario attacks, working with passwords, and data encryption. Chapter 19 describes how to make your application user-friendly from other countries; it also provides 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 built-in PHP web server. Chapter 22 explains how to compare the performance of two functions and make programs run at maximum speed. Chapter 23 discusses regular expressions, saving text from HTML tags, calling PHP functions from regular expressions, and using maximum and minimum searches.

    Chapters 24 and 25 deal with the file system. Chapter 24 is limited to file operations: opening and closing, using temporary files, setting a lock, transferring compressed files, processing file contents. Chapter 25 discusses directories and file metadata, and her recipes discusses changing permissions and ownership, moving and deleting files, processing 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 you can do with PHP outside of web programming. These recipes cover topics related to command line mode, such as parsing program arguments and reading passwords. Chapter 27 introduces the reader to the Composer, PEAR (PHP Extension and Application Repository) and PECL (PHP Extension Community Library) repositories. Composer and PEAR provide access to the PHP code, which provides functions and extensions for PHP. PECL also contains a selection of PHP extensions, but written in C. The PEAR and PECL modules are used repeatedly in the book, and Chapter 27 describes the process of installing and updating them.

    About Authors

    David Sklar is an independent technology consultant. In addition to the book PHP Cookbook, he is also the author of 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.

    Adam Trachtenberg is the leader of the LinkedIn Developer Network, 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 of Science in Mathematics and a Master of Business Administration degree from Columbia University.

    The book can be found in more detail on the website of the publishing house.
    Contents
    Excerpt

    For Habrozhitelami there is a 25% discount on coupon - PHP

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

    Read Next