Fundamentals of the PHP Programming Language


PHP is a programming language that is most widely used in web development.

Currently, PHP is one of the leading server-side programming languages ​​used to create dynamic websites and web applications. Most of the boxed content management systems are written in PHP, the language is supported by the vast majority of hosting providers. The language has become widespread due to its simplicity, speed, multi-paradigm, rich functionality and cross-platform.

PHP development platforms

Paid boxed CMS: 1C-Bitrix, UMI.CMS, NetCat

Free boxed CMS: ModX, Drupal, Joomla, WordPress

Frameworks: Yii, Symfony, Zend

Criticism

The language is popular, but at the same time, the average level of developers is catastrophically low: even novice HTML coders call themselves PHP programmers. This will largely determine the poor quality of PHP projects.

The frameworks are quite scattered – there are many of them, there is no clear leader, so the number of developers on a single PHP framework can be significantly lower than the number of developers on the same Ruby on Rails (although the Ruby programming language itself is much less common than PHP).

Also, the language itself has a fairly large number of shortcomings that manifest themselves when developing complex solutions. In many ways, these shortcomings are a consequence of the evolutionary development of PHP and the pursuit of backward compatibility.

PHP is a language for web development, which can be called the main one for the “mass market”, that is, for developing typical sites on boxed CMS.

PHP is a general purpose scripting language often used to develop websites.

PHP is an interpreted programming language that allows you to create programs in a procedural and object-oriented style. PHP is a good language for developing CMS projects. And from a technical point of view, modern PHP is quite good. But the ecosystem of the language and the peculiarities of the staffing market make PHP not the best choice for developing complex projects.

The main advantages of PHP are most often cited as widespread, fairly high demand for PHP developers, combined with a low entry threshold for training.

PHP is often criticized for inconsistent function syntax, non-orthogonal design, backward version incompatibility, and a very low average development culture.

In fact, the ease of learning and the high level of demand in very simple projects are precisely the reasons for the low average level of technical expertise and development culture in this language. It’s just that so many of those who call themselves PHP developers actually don’t even have the basic knowledge to be called programmers. And a large number of projects with low quality requirements gives rise to an almost ubiquitous application of the methodology, softly called “fuck-fuck and in production.”

Of course, in PHP development there are also very good programmers who work using the best practices in the field of software development. But they are not so easy to find, so the average level of technology is determined not by them, but by a huge number of webmasters who create trivial sites using the simplest possible technological process.

We faced a personnel problem with the complexity of the projects being implemented. In PHP, it is quite easy to find developers who can build a site on a boxed CMS system, especially if there are no requirements for its speed, reliability and security. As soon as the requirements for the technical characteristics of the project become more stringent or when development on a framework with high-quality architecture is required, the personnel market in the PHP ecosystem leaves much to be desired.

In principle, there are few really good programmers in any programming language, but our practice has shown that finding them within the PHP stack is a more difficult task compared to other languages: Ruby, Python, GoLang, Java. This was one of the reasons why we decided in 2013 to change the technology stack, moving from the ubiquity of PHP to the use of Ruby for web development and to the use of Python for data analysis. The difference in the ecosystems of these programming languages ​​also played a role – Ruby and Python turned out to have more high-quality tools that we need to implement complex projects. Even in Ruby and Python, the developer community is concentrated around a small number of powerful frameworks and libraries, while in PHP there are several hundreds of varying degrees of popular frameworks and CMS. In other words, a randomly selected Ruby web developer in 99% of cases already knows and worked with Ruby on Rails, a Python web developer knows Django with a 95% probability, but in PHP there is simply no such clear leader among the platforms.

Functions in php

Often, in programming languages, programming has to perform some actions of the same type more than once. Functions were created specifically to avoid code duplication (repetition of this code).

Functions are just some named piece of code that you can call to perform a certain set of actions.

Let’s see how you can work with functions in the PHP programming language.

In order to create a function in the PHP language, a special construction is used:

function function_name() {

    team 1;

    team 2;

    …

}

Note that parentheses are written after the function name. These parentheses indicate that this is a function and that this function can have arguments. And the curly braces indicate the set of arguments.

This is how php functions are created. Now you can refer to it and perform the set of actions specified in it as many times as you like.

To call a function, simply specify its name:

function_name();

You can call a function even before it has been declared, everything will work

You can call the function as many times as you like:

function_name();

function_name();

function_name();

The function was created in order to shorten the program code.

Functions can be created as many as you like, and thus they are created in the PHP language.

As with any programming language, PHP has special code constructs called comments.

Comments are code constructs that are not parsed by the PHP language. As commands or statements, they are not executed, but nevertheless, they are present in the source code of the document.

Let’s see how we can make comments inside PHP. Comments must be inside the <?php ?> construct.

In order to make a comment, you need to use the following construction:

// Comment

This is the so-called single-line comment and it operates within one line. If we move to another line, the comment stops working.

With the help of comments, you can remove some part of the code from the action, or you can leave some notes for yourself.

// This is a test of the assignment operator.

In addition to single-line comments, PHP allows you to create multi-line comments.

They remain active until we close them.

They look like this.

/*

Comment.

from

multiple lines

*/

This is how you can work with comments in PHP. There is nothing complicated. Try to work with this too.

Leave a Reply

Your email address will not be published. Required fields are marked *