0Pricing
PHP Academy · Lesson

PHP Tags and Embedding Syntax

Use opening/closing PHP tags and short echo syntax inside HTML.

Mixing PHP and HTML

PHP was designed to embed inside HTML files. When the server processes a .php file, everything between PHP tags is executed; everything else is sent to the browser as-is.

Standard PHP Tags

The standard opening and closing PHP tags:

<!DOCTYPE html>
<html><body>
<?php
    $name = 'Alice';
    echo 'Hello, ' . $name;
?>
<p>This is regular HTML.</p>
<?php
    echo '<p>Back in PHP!</p>';
?>
</body></html>

All lessons in this course

  1. PHP Tags and Embedding Syntax
  2. Dynamic HTML with PHP Loops
  3. Including and Requiring Files
  4. Template Pattern: Separating Logic from View
← Back to PHP Academy