- The PHP interpreter parses files looking for <?php ... ?> code blocks
- Anything outside of a <?php ... ?> block is passed directly to the output stream
- Anything inside a <?php ... ?> block is parsed and interpreted as PHP code
The first uses of PHP were for dynamic HTML pages like:
<?php include_once('dynamic-news.php'); ?>
<html>
<head><title><?php getname(); ?>'s custom news</title></head>
<body>
<h1>Welcome, <?php getname(); ?></h1>
<p>In today's news:</p>
<?php print getHeadlines(); ?>
</body>
</html>
- While this is a simple approach for generating dynamic content used by sites like Yahoo today, many new PHP applications are written entirely within <?php ... ?> blocks, and increasingly model-view-controller patterns are being adopted to allow for easier reuse and division of labour
- Some PHP projects (like Smarty) have created templating languages built in PHP -- a rather circular effort!