1/* PHP code can be easily injected into a standard HTML page. As a rule,
2 * files with mixed content of that kind have .phtml extention. The workflow
3 * is the same as for pure .php scripts: one should setup web-server to
4 * handle .phtml files the same way it handles .php - .phtml should be passed
5 * to PHP engine, and the outcome gotta be sent to a visitor. PHP will parse
6 * the .phtml and process everything inside tags <?php [..] ?>, ignoring the
7 * rest. I.e. the php code pieces in .phtml will be replaced in outcome with
8 * results of their processing, and HTML / CSS / JavaScript code in .phtml,
9 * as well as text content, will be displayed in browser as is. The one and
10 * only strict rule - your .phtml mixes must always start with PHP tag
11 * sequence <?php ?>, otherwise they won't be preprocessed by PHP engine.
12 */
13
14<?php
15/**
16 * @category Template
17 * @package Hello_World
18 */
19
20$tpl = 'Hello %s!';
21
22?>
23<!doctype html>
24<html lang="en">
25<head>
26 <title><?php printf($tpl, 'World'); ?></title>
27 <style>
28 body {
29 text-align: center;
30 }
31 </style>
32</head>
33<body>
34 <h1><?php printf(
35 $tpl,
36 'world of ' . date('Y') . ', the wonderful future world'
37 ); ?></h1>
38</body>
39</html>
40
41<!-- In a browser this template will display "Hello world of 2021,
42 the wonderful future world!" with "Hello World!" in title -->