Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

PHP tutorial No. 1: Introduction

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:

<?php $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 () 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.

Rasmus Lerdorf


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

3 years ago
You are viewing a single comment. View All

nice, this is my full php/laravel site, I also have a fast YouTube coverter here

1 year ago