PHP tutorial No. 1: Introduction
malvoliothegood (781)

PHP tutorial No. 1: Introduction has recently added a PHP web server 'new repl' option that combines a PHP parser (program) with an HTML web server. This means that within a web page's HTML you can embed PHP code between special opening and closing tags like so:

    $message = "PHP is so cool!!";
    echo "<p>Hello <strong>$message</strong></p>";

After the above code is processed by the PHP parser a string of HTML will be injected (by the echo command) into the page's HTML code at the location where the PHP code occurs. For the code above the resultant string will be:

"<p>Hello <strong>PHP is so cool!!</strong></p>"

In the browser the results is a paragraph with Hello being displayed as plain text and PHP is so cool!! being displayed as bolded text.

Note that the web page's file name will need to have a file extension of php.
The PHP parsing engine will process the page's code because it has this extension. Any HTML or CSS code will be left untouched, and any code between opening and closing PHP tags (<?php and ?>) will be treated as PHP code, processed and converted into an HTML string that is "injected" into the page's code at the point where the PHP code occurs. When the page's code has been completely parsed it is passed to web server software which delivers it to the browser that requested it.

The following link points to a Wikipedia article about PHP that backgrounds it's development: PHP

The following link points to a simple example of PHP code used within HTML: A simple example of using PHP within HTML

Below is a picture of Rasmus Lerdorf. He invented PHP in 1994.


The following link points to the official PHP language reference website.
PHP language reference

However, it can be a bit technical. The following link points to an easier one to understand tutorial. It also includes example programs using an online IDE
Tutorialspoint: Learn PHP

Next tutorial: PHP variables

You are viewing a single comment. View All