⊗ppPmBsRn 3 of 447 menu

PHP Code Execution

Let's assume you already have a PHP server installed. In it, your programs will be located in files with the extension php. These files are actually just regular HTML files in which we can write the HTML code of our pages, like this:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Моя первая программа</title> </head> <body> моя первая программа </body> </html>

In these files, right inside the HTML code, we can write PHP code. It is written in special brackets <?php and ?>. Let's do this:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Моя первая программа</title> </head> <body> <?php echo 'моя первая программа'; ?> </body> </html>

If you run this file through a PHP server, the server will execute the PHP commands and send the result to the browser. The command echo, which you can see there, simply performs the output of the specified string. As a result, only the HTML code will be sent to the browser, and instead of the PHP code there will be the result of its execution.

For simplicity, at the learning stage, extra tags can be omitted:

<?php echo 'моя первая программа'; ?>
byenru