main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php 
$name = '';
$age = '';
$error = '';

// Simples post data management
if (isset($_POST['name'])) {

	$name = $_POST['name'];
	$age = $_POST['age'];

	if (empty($name)) $error = 'Fill the name.<br />';
	if (empty($age)) $error = 'Fill the age.<br />';

	// Some dynamic content to test HEREDOC expression in Repl.it
	if (empty($error)) $error;
} 

// Trying some HEREDOC below
<<<HTML
<html>
	<head>
		<title>Form</title>
	</head>
	<body>
		<form method="post">
			<div>
				<label for="name">Name</label>
				<input type="text" id="name" name="name" value="{$name}" />
			</div>
			<div>
				<label for="age">Age</label>
				<input type="text" id="age" name="age" value="{$age}" />
			</div>
			<input type="submit" text="Send" />
		</form>

		{!empty($error) ? $error : 'Everything OK!'}
	</body>
</html>
HTML;
?>
PHP 7.0.8 (cli) (built: Jun 23 2016 23:39:14) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies