データ入力時のみデータを処理する

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>データ入力時のみデータを処理するには?</title>
</head>
<body>
<?php
$example = isset($_POST['example']) ? $_POST['example'] : NULL;

if (strlen($example) > 0) {
  echo '<p>データを受け取りました: ' . h($example) . '</p>';
} else {
  echo "<p>データを受け取っていません</p>";
}

function h($string) { // HTMLでのエスケープ処理をする関数
  return htmlspecialchars($string, ENT_QUOTES);
}
?>
<form method="post" action="">
<p>テキストボックス</p>
<input type="text" name="example" />
<input type="submit" value="送信" />
</form>
</body>
</html>