Skip to content

Instantly share code, notes, and snippets.

@teresko
Last active August 29, 2015 14:27
Show Gist options
  • Save teresko/6d761c65b573d309c1c8 to your computer and use it in GitHub Desktop.
Save teresko/6d761c65b573d309c1c8 to your computer and use it in GitHub Desktop.

Basic syntax

PHP tags

[PHP tags][php-tags] are used to let PHP know which part(s) of a file it needs to parse. Because of this we can mix PHP and another language (e.g. HTML). To start the parsing of code in a file you need to add the PHP opening tag <?php and to end the parsing of code in a file you need to add a PHP closing tag ?>. Everything outside of the PHP tags will be left alone by the parser and will just work like normal. A simple example of this using a simple HTML document:

<html>
  <head>
    <title><?php echo 'This is the page title'; ?></title>
  </head>
  <body>
    <h1><?php echo 'This is the heading of the page'; ?></h1>
    <p>This is a paragraph...</p>
  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment