0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<h2>PHP</h2>
1
<h2>PHP</h2>
2
<p>PHP is a preprocessor language. It can be used to assemble pages from smaller pieces, like an erector set. It can also execute logic, such as showing a sign-up form to new users, but bypassing it for known users. PHP turns the code of the assembled pages into HTML. This is what is called preprocessing.</p>
2
<p>PHP is a preprocessor language. It can be used to assemble pages from smaller pieces, like an erector set. It can also execute logic, such as showing a sign-up form to new users, but bypassing it for known users. PHP turns the code of the assembled pages into HTML. This is what is called preprocessing.</p>
3
<h2>Comments</h2>
3
<h2>Comments</h2>
4
<p>Comments provide an explanation in natural language. Programmers leave them for other developers in order to explain their software code. Code that is enclosed in a comment is not executed and does not affect the output.</p>
4
<p>Comments provide an explanation in natural language. Programmers leave them for other developers in order to explain their software code. Code that is enclosed in a comment is not executed and does not affect the output.</p>
5
<p>You can make a single-line comment in PHP by writing two forward slashes //. Code<b>on the same line</b>after these characters will be commented out. In order to remove a comment, you need to delete //.</p>
5
<p>You can make a single-line comment in PHP by writing two forward slashes //. Code<b>on the same line</b>after these characters will be commented out. In order to remove a comment, you need to delete //.</p>
6
// I am comment text. I do not affect the program // like the code below // require('path_to_file.php');<h2>Syntax</h2>
6
// I am comment text. I do not affect the program // like the code below // require('path_to_file.php');<h2>Syntax</h2>
7
<p>Syntax governs word order and the rules for writing words. The computer uses syntax in order to understand what we write. Every programming language has its own syntax.</p>
7
<p>Syntax governs word order and the rules for writing words. The computer uses syntax in order to understand what we write. Every programming language has its own syntax.</p>
8
<h2>Commands</h2>
8
<h2>Commands</h2>
9
<p>A command is an instruction to a program to perform some action.</p>
9
<p>A command is an instruction to a program to perform some action.</p>
10
<p>The require command adds code from the specified file to the page where require is used:</p>
10
<p>The require command adds code from the specified file to the page where require is used:</p>
11
require('path_to_file.php');<p>PHP has other commands for including files. For example, include. You can learn more about this command in the<a>specification</a>.</p>
11
require('path_to_file.php');<p>PHP has other commands for including files. For example, include. You can learn more about this command in the<a>specification</a>.</p>
12
<p>Each command must be written on a new line, and each line must end in a semicolon: ; . This is how we tell PHP that we are finished writing one command and that what comes after is another command.</p>
12
<p>Each command must be written on a new line, and each line must end in a semicolon: ; . This is how we tell PHP that we are finished writing one command and that what comes after is another command.</p>
13
<h2>Concatenating files</h2>
13
<h2>Concatenating files</h2>
14
<p>When you add files to PHP, they are concatenated together. When a require command is encountered during the execution of a script, it is replaced with the contents of the included file in the exact order in which the require commands occur.</p>
14
<p>When you add files to PHP, they are concatenated together. When a require command is encountered during the execution of a script, it is replaced with the contents of the included file in the exact order in which the require commands occur.</p>
15
require('header.php'); require('content.php'); require('footer.php');<p>In the example, the content markup will be added to the header layout, and then the footer markup will be added to them.</p>
15
require('header.php'); require('content.php'); require('footer.php');<p>In the example, the content markup will be added to the header layout, and then the footer markup will be added to them.</p>
16
<h2>PHP tags</h2>
16
<h2>PHP tags</h2>
17
<p>For the PHP code to work, it must be placed inside PHP tags:</p>
17
<p>For the PHP code to work, it must be placed inside PHP tags:</p>
18
<?php // Opening PHP tag // Some sort of PHP code ?> // Closing PHP tag<p>Tags work like a signal. When we use them, we are saying something like “Pay attention: there is PHP code inside”.</p>
18
<?php // Opening PHP tag // Some sort of PHP code ?> // Closing PHP tag<p>Tags work like a signal. When we use them, we are saying something like “Pay attention: there is PHP code inside”.</p>
19
<p>Sometimes the closing tag can be omitted. For example, when we work with a script that only contains PHP code. If we embed a PHP code fragment in HTML, then the closing tag must be used. This is how we mark the boundaries of the PHP code inside the template.</p>
19
<p>Sometimes the closing tag can be omitted. For example, when we work with a script that only contains PHP code. If we embed a PHP code fragment in HTML, then the closing tag must be used. This is how we mark the boundaries of the PHP code inside the template.</p>
20
<h2>Variables</h2>
20
<h2>Variables</h2>
21
<p>Variables provide a way to save information under a specific name. A variable<b>declaration</b>is used to write the variable name when it is first mentioned. When we write information to a variable, we say that we are<b>assigning</b>values.</p>
21
<p>Variables provide a way to save information under a specific name. A variable<b>declaration</b>is used to write the variable name when it is first mentioned. When we write information to a variable, we say that we are<b>assigning</b>values.</p>
22
$name = 'Semyon'; // We declared the variable $name // We assigned the variable the value 'Semyon'<p>The variable name must begin with the dollar sign $. The next character may be either a letter or an underscore. The name should be human-readable and describe what is contained in the variable.</p>
22
$name = 'Semyon'; // We declared the variable $name // We assigned the variable the value 'Semyon'<p>The variable name must begin with the dollar sign $. The next character may be either a letter or an underscore. The name should be human-readable and describe what is contained in the variable.</p>
23
<h2>Templates</h2>
23
<h2>Templates</h2>
24
<p>Page templates store code placeholders. A template can be static or dynamic, that is, it can include variable data.</p>
24
<p>Page templates store code placeholders. A template can be static or dynamic, that is, it can include variable data.</p>
25
<h2>Adding PHP to the page markup</h2>
25
<h2>Adding PHP to the page markup</h2>
26
// Full notation <p><?php echo($name); ?></p> // Short notation <p><?= $name ?></p><p>These two options work in the same way. The only difference is in the number of characters.</p>
26
// Full notation <p><?php echo($name); ?></p> // Short notation <p><?= $name ?></p><p>These two options work in the same way. The only difference is in the number of characters.</p>
27
<h2>Database</h2>
27
<h2>Database</h2>
28
<p>A database is a system that stores site information in an organized manner.</p>
28
<p>A database is a system that stores site information in an organized manner.</p>
29
<h2>Working with an address</h2>
29
<h2>Working with an address</h2>
30
<p>The address bar is a special field in the browser where the user can enter a the address (URL) of a page on the Internet.</p>
30
<p>The address bar is a special field in the browser where the user can enter a the address (URL) of a page on the Internet.</p>
31
<p>The address has a special part that is called the “query parameters”. The query parameters are entered after the question mark.</p>
31
<p>The address has a special part that is called the “query parameters”. The query parameters are entered after the question mark.</p>
32
https://www.gloevk.com/product.php?product_id=1<p>You use the $_GET command to get information from the address.</p>
32
https://www.gloevk.com/product.php?product_id=1<p>You use the $_GET command to get information from the address.</p>
33
<p>For example, if you would like to get the value product_id using $_GET, you would write $_GET['product_id'].</p>
33
<p>For example, if you would like to get the value product_id using $_GET, you would write $_GET['product_id'].</p>
34
<a>Continue</a>
34
<a>Continue</a>