What is PHP?

PHP programming language is a server language with which you can create websites, both small landing pages consisting of one page and giant systems using hundreds and thousands of servers. Wikipedia, Facebook,, etc. created using PHP.

Being one of the very first programming languages ​​focused on Web development, PHP ran a long way from the very beginning of the birth of the Web. Therefore, in the world it remains one of the most popular and sought-after languages.

Advantages and disadvantages

At the heart of the popularity of PHP are the following advantages:

  • Web Development Orientation – PHP was created, developed and maintained as a language for creating Web sites. Many designs and solutions in it are created for the convenience of working in a Web environment.
  • Cross-platform – PHP is transferred to all major operating systems: you can develop a website in Windows, Mac OS X, and operate on a Linux-server. The complexity of the transfer will be minimal and leveled language.
  • Free of charge – PHP is a development from the world of free software, you don’t need to pay either for the language itself or for the majority of related programs (editors, Web servers, databases). In addition, most software products with which you have to deal will have source code available for review and modification. Money may be required when renting a domain name and server for publishing a site on the Internet. However, it is possible to study PHP without investing a penny.
  • Low entry threshold – explore PHP and start building ready-made applications on it a lot easier than using competing technologies (.NET, Python, Ruby, Go). Studying PHP does not close other technologies for the developer; on the Web, the language itself is a significant, but smaller part of the technologies used. Knowledge, techniques, related technologies (Web-servers, databases, libraries, auxiliary languages) will be useful in any other ecosystem other than PHP. When creating your own business, it is often easier and cheaper to assemble a team of PHP developers.

According to the law of conservation, any thing that has at least some dignity, has flaws. PHP also has them.

  • Lack of a leader – many technologies and languages have a leader, an architect who determines the appearance of technology, sets the development vector, decides what should be and what will never be (Linux, Python, Ruby, etc.). There is no leader in PHP, many solutions and constructions are a compromise of interest groups and historical realities.
  • Inconsistent syntax – when learning the PHP language, especially the old part, based on functions, you may notice that some of the functions have the prefixes array_, str_, some have not. The parameters of the functions may be located not entirely logical and not the same as in another function of the same group.
  • PHP is already a long-living language. When a language first appears, it is rather elegant and internally consistent. As the life cycle progresses, the language acquires with additional keywords, artifacts, outdated constructions that seem to be working, but which are not recommended to use. PHP had a rather stormy youth, in the course of which a mass of directives and techniques were abolished, which at first glance should have facilitated the development, and in practice turned into serious security problems. PHP itself, launched as a non-object-oriented language, has now become a full-fledged object-oriented language. However, it is full of old procedural artifacts that will have to use.
  • The PHP developer community is large and disconnected because PHP is one of the first technologies for developing Web-projects, half of the Internet was created with its participation. At the same time, a huge number of programmers worldwide were involved in PHP development. All this has generated a large number of very different approaches, frameworks and ecosystems incompatible with each other. Moreover, thanks to the efforts of powerful and influential social networks (primarily Facebook, alternative implementations of PHP have appeared. This is bad, because many ecosystems within PHP are not compatible, and the community is fragmented and spends effort on creating the same libraries within different groups. The situation is corrected with the help of PSR standards. Developers agree on common rules and interfaces for framework compatibility, but this process is still at the beginning, while competing technologies (.NET, Ruby) already have a single platform for all frameworks.

PHP structure

The PHP language has a core and language extensions. It is rather difficult to draw a boundary between the kernel and extensions, since many extensions have long been included in the kernel or distributed as compiled binary libraries and are easily installed.

There is another part – the code created in PHP, which can be divided into the following types:

  • components are PHP libraries that are built using the Composer package manager (see Chapter 26);
  • frameworks – ready-made assemblies, often from components with which you can create sites of any degree of complexity. In the book, unfortunately, we don’t touch them, however, if you choose PHP as the main development language, you won’t pass them by. The following PHP frameworks should be noted: Symfony, Laravel, Zend, Yii. There are hundreds, if not thousands;
  • ready applications – ready-to-use development on PHP. These are content management systems (WordPress, Drupal), forums (phpBB), Web-based database management interfaces (phpMyAdmin, pgAdmin).

The book you hold in your hands will introduce you to the language; The systems described above are created using the PHP language, but they require separate study and, unfortunately, their discussion is beyond the scope of our book.

Related Technologies

With PHP, you can quickly develop Web sites, but modern PHP implementations are not the fastest and most efficient part of a site. Therefore, to run the site will require additional software and technology.

  • A web server is a program that provides interaction between the client and your application through the HTTP protocol. Throughout the book, we use the built-in PHP server (see Chapter 3), although the operation of this site will require an Nginx or Apache Web server.
  • Database server – data needs to be stored somewhere. The book covers in some detail two databases: PostgreSQL (see chapters 27-28) and Redis (see chapters 29-30). However, this is not all databases that you will meet in practice, and each of those affected deserves a separate book.
  • The Git version control system, which serves to store development history, backup copying, delivering code to the server, organizing team work. Whether you work in a team or alone – Git is currently becoming the main tool of a modern programmer, whatever programming language is chosen as the base one.

The list goes on and on. However, in fact, you can start even without it – simply relying on the language of PHP. If you are wondering what awaits you after studying PHP, look at the conclusion.


Install Git and download the source for the book from GitHub:

Object oriented approach

Before PHP 5, support for object-oriented programming (OOP) in the language was rather poor. In PHP 5, the object-oriented approach has long remained an alternative to the traditional procedural approach. PHP 7 is almost entirely designed for object-oriented development. Without OOP, the development of modern PHP applications is impossible: more and more extensions involve an object-oriented interface, components are designed as classes, PSR-standards and modern frameworks dictate a design that is completely oriented towards an object-oriented approach. That is why to get acquainted with the object-oriented approach, we begin immediately with the first chapters of the book. We consider design patterns and, where possible, focus on new extensions with an object-oriented interface.

PostgreSQL and Redis

Traditionally, PHP applications work in conjunction with MySQL. The rare PHP book does not focus on this popular database. However, we will depart from the tradition.

On the one hand, the resale of AB MySQL to Sun Corporation, which in turn was absorbed in 2009 by Oracle, led to the fact that the most popular free DBMS was in the hands of the world’s largest manufacturer of commercial databases. The development of MySQL, if not stagnant, is significantly inferior to competing databases, for example PostgreSQL, which for a long time remained on the sidelines.

On the other hand, the development of an object-oriented approach and an increase in the amount of memory on the servers led to a surge in interest in non-relational databases, which took the form of the NoSQL movement. PostgreSQL is not exactly a traditional DBMS. Conceived as an object-oriented database, PostgreSQL anticipated the SQL movement for several years. Therefore, today you can already see how most modern Web applications migrate to PostgreSQL.

In addition, instead of the traditional memcached, we consider the NoSQL Redis database. As a rule, modern Web applications cannot do without one or several NoSQL databases, so it is not possible to bypass them with attention. Redis stands out among them for its high performance (100,000 RPS-request per seconds), rich features (collections, clustering, PuL / Sub mechanism).


We do not consider a detailed installation of a full-fledged environment, including a Web server, setting up its connection with PHP, ensuring secure access to a remote server. Instead, use the built-in PHP server, immediately available when installing PHP.

Due to limitations on the volume of the book, it was necessary to abandon the description of many features of PHP, for example: detailed consideration of sockets, curl extensions, mathematical functions, image conversion, output buffer management, regular expressions and even file functions. All these possibilities are beyond the scope of the book.

Instead, each chapter is provided with tasks that encourage researching documentation, becoming familiar with functions and extensions not included in the book, researching alternative databases, reading articles, and searching for a solution. Only 100 tasks.

Source codes

At the beginning of each chapter (with the exception of the 1st and 29th) there is a directory where you can find examples of this chapter, the file names are listed in the headings for the listings.

The source code for the book can be found on the GitHub account at:

Follow the link below to send questions to the authors:

The electronic archive with source codes for the book can also be downloaded from the link This link is also available from the page of the book on the website

Words of gratitude

We thank the authors Maxim Kuznetsov and Igor Simdyanov.

From Igor Simdyanov: “We wrote many books with Maxim Kuznetsov, and the first edition of this book was the start of our collaboration. Five years, as he is not with us: he lived quickly, brightly, helped many, it would seem, in desperate situations. This edition of the book is dedicated to him.”

/ October, 15 at 18:40

I create web projects, develop, optimize and promote websites. If you have any ideas or want to suggest something, then write to me and my team.

Top ↑

Leave a Reply