Key Concepts

Review core concepts you need to learn to master this subject

Dynamic Webpages using PHP

PHP is a server scripting language. This server side code can be used to fill out HTML templates in order to create a complete HTML document for a visitor. This finished document is called a dynamic webpage.

Dynamic PHP webpages can deliver a custom set of assets to each visitor, unlike static pages which deliver the same set of assets to everyone.

Embedding PHP Code

PHP can generate HTML when saved as a file with a .php extension. These files must always start with the tag <?php (closing tag is optional).

PHP can also be embedded into HTML. In this case, both opening tag <?php and closing tag ?> are used.

For example, in the given code, the PHP code has been embedded into the HTML by enclosing it within the <?php and ?> tags.

$_REQUEST Superglobal Variable

The $_REQUEST superglobal variable is an array that contains data from the clients cookies, GET and POST request.

Action Form Attribute

The “action” form attribute is used to specify which PHP file handles the request being submitted. The PHP file handling the request can be the same file sending the request or a separate file.

$_POST Superglobal Variable

$_POST, the PHP superglobal variable, is an array that contains data from the client’s POST request. This data is translated from the HTTP request headers

$_GET Superglobal Variable

$_GET is a PHP superglobal variable which is used to collect an array of data transmitted within the URL parameters of a client’s incoming GET request.

echo Shorthand Syntax

Instead of using the regular echo syntax like <?php echo "Hello World"; ?> we can use a shorthand syntax such as <?= "Hello World"; ?>.

HTML Form Name Attribute

The name attribute is used to associate data with an input tag so that PHP can access the data. Unique name attribute values are needed for each input tag.

  1. 1
    PHP can be used in many ways. It can be used to write standalone programs that run in our terminal: echo “Hello, World!”; When run, the code above will output the following to the terminal: Hell…
  2. 2
    Let’s talk about the difference between a front-end language and a back-end language. HTML is a front-end language, but what exactly does that mean? When navigating to a website from our web brows…
  3. 3
    The back-ends of websites will differ depending on the needs of the site. Typically, they’ll have at least the following components: 1. A web server: a web server is a computer or program which l…
  4. 4
    We can embed PHP scripts within HTML documents with the opening tag . The PHP processor will read the entire file, evaluate any PHP, translate it into HTML, and pass it off to the web server so i…
  5. 5
    We can also incorporate more complex PHP within our scripts. Your lucky number is ${lucky_number} “; ?> The code above will be translated into HTML with a header that reads: Your lucky number is…
  6. 6
    In this lesson, you’ve begun to learn how to use PHP to generate HTML. This will become even more powerful as we learn how to get information from the client and use that to create dynamic websites…
  1. 1
    Presenting and interacting with HTML is one of the primary uses of PHP. Our server takes each PHP file (in our examples, this is index.php), and translates them into HTML to present to the clie…
  2. 2
    Since PHP was built with web development as a primary use case, it has functionality to ease processing of HTML requests. When the front end client makes a request to a backend PHP server, several …
  3. 3
    In HTML, setting a form’s method attribute to “get” specifies that you would like the form to be submitted using the GET method. When using this method, the form entries are passed as parameters in…
  4. 4
    In HTML, setting a form’s method attribute to “post” specifies that you would like the form to be submitted using the POST method. When using POST to submit forms, you will not see the URL change. …
  5. 5
    Until now, we’ve been handling the response to the form submission on the same page as the form itself. Often times there is no need to present a user with the same form over and over again. It mig…
  6. 6
    You’re ready to start handling forms in PHP! To review: - <?= is shorthand for <?php echo. - PHP provides superglobals which can be accessed anywhere in the script. - $_GET is an associative …

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo