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.

Chevron Left Icon
PHP and HTML
Lesson 1 of 2
Chevron Right Icon
  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: Hello…
  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