What is PHP

Let’s start by defining exactly what PHP is. It is difficult to give a complete picture of this language in one sentence, so we will describe it with the following three characteristics:

PHP is a hypertext (HTML) preprocessor.
PHP – a server-side programming language.
PHP is a scripting, interpreted programming language.

Why PHP is needed
Let’s explain each of the definitions and find out in what tasks PHP is useful.

The main task of PHP is to “animate” HTML pages.

Conventional HTML pages are static. Static (or not static) means that after a page has been created and uploaded to the site, every time that page is accessed, the browser will display it to any user in the same form.

But that’s not always enough.

Almost always users come to the site for information that changes all the time, and you need to display its current state. For example:

show the exchange rate;
show the weather for tomorrow;
Display a counter of visits to the page.

If you use only HTML, then it will not be possible to solve such problems. This is where we need PHP. It takes an incoming request from a web-server, executes a script, and returns the result to the web-server as ready-made HTML code. The server sends this result to the user in the browser, which in turn displays it to the user. You can then see the latest exchange rates, the weather, and anything else you want.

RNR allows you to modify a web page on the server just before it is sent to the browser. Let’s see how that works. PHP can execute code known as scripts. At runtime, PHP can modify or dynamically create any HTML code, which is the result of the script. The server then sends this code to the browser. The browser does not know how the page was formed – whether it was statically created by the codifier, or dynamically created with PHP. This does not matter, because the browser always works only with what it receives from the server.

Let us remember that a script is a program that resides on the server side and runs in response to a request from the browser.

We can now understand why PHP is called a hypertext preprocessor. When the browser requests a page with an address that ends in .php, the web server calls PHP and asks it to run a script from the file at that address.

Executing the script is also called interpreting it, and PHP itself is called an interpreter.

You can practice creating dynamic pages with PHP in this simulator.

Where to use PHP
The main area of application of the language of PHP – the web, that is, the sites that we visit every day through the browser of a computer or smartphone. It is important to understand that the web is not the entire Internet, but only its largest and most popular part. In addition to the web, the internet is also used for email, instant messengers, file exchange services, online games and much more.

Almost every site that is on the Internet, running on PHP. This language is great for any dynamic website, including:

social networks;
blogs and forums;
online stores;
browser games.

What a PHP script looks like
A typical PHP script is a collection of expressions. Each expression starts on a new line and ends with a semicolon.

An expression is an instruction which tells the PHP interpreter to do something, such as sum up two numbers or display information.