How Php Works

Table of contents:

How Php Works
How Php Works

Video: How Php Works

Video: How Php Works
Video: How PHP Works 2024, December
Anonim

PHP is a programming language (PL) that is widely used to write programs for various Internet sites. Its main specificity is that all the code is executed on the server side, and the result of the work is subsequently displayed in the user's browser as HTML content.

How php works
How php works

Instructions

Step 1

The code written in the PHP file runs independently of the user's computer on the remote server. When you visit the site, the browser window displays HTML content that was received from the addressed server, i.e. the computer on which all the components of the site are stored.

Step 2

When you go to the site, the browser sends a signal, in response to which the server starts returning the necessary elements to the program in hypertext format. When accessing a PHP page, the server, using the command interpreter, executes the instructions specified in the code, performing the necessary computational operations. After their completion, the result of the program is also generated in HTML and sent to the user in the finished version.

Step 3

The execution time of the script by the remote computer will vary depending on the complexity and massiveness of the code, as well as the speed of the server on which the site is located. It should be noted that if the corresponding set of libraries and instructions for PHP is not installed on the hosting provider's machine, the script will not be launched, which means that the required page in the browser window will not be loaded.

Step 4

Depending on the user's actions, the required signal is sent to the server from the browser. For example, after filling out the data of the registration form, all the specified data in the appropriate format is sent to a remote computer, which checks the correctness of filling. If any field was filled in incorrectly, the machine sends a request to the browser to indicate incorrect data in accordance with the requirements. As soon as the correctly filled information is sent to the server, it is saved, and a message is sent to the browser that the registration was successful.

Step 5

A program written incorrectly in PHP will not function properly no matter what the user or the server does. If PHP code cannot be processed, the remote machine sends a corresponding message to the browser, which is displayed on the monitor.

Step 6

With each new call to the page, the PHP script is restarted, which means that each page is processed independently of the previous request. For example, when you move on a site from one page to another, separate programs are executed, which are usually not related to each other, but at the same time form a single structure. If it is necessary to transfer data from one PHP file to another, the corresponding PL directives are used.

Recommended: