If you are putting in large wads of html, use here docs to make your life easier. Observe:
Note: I use if for pretty much everything, but use switch if you think it's sexier.
<?php
if (!isset($page) || empty($page)) {
$page = 1;
}
$next = $page + 1;
$prev = $page - 1;
if ($page == 1) {
$prev = 1;
print <<<EOQ
<b>Welcome to my fantastic website. This is the first page.</b><br>
Click <a href="page.php?page=$prev">here</a> to goto the previous page<br>
Click <a href="page.php?page=$next">here</a> to goto the next page<br>
My email: <a href="mailto:loser@mypage.com">loser@mypage.com</a>
EOQ;
} else {
print <<<EOQ
<b>I am revolted to find out that you want to see more crappy pages! You are on page $page</b><br>
Click <a href="page.php?page=$prev">here</a> to goto the previous page<br>
Click <a href="page.php?page=$next">here</a> to goto the next page<br>
My email: <a href="mailto:loser@mypage.com">loser@mypage.com</a>
EOQ;
}
?>
You see, with here docs, you don't have to escape your quotation marks and it still parses basic variable names like php. Here docs are my friend 🙂
Here docs are only available on PHP4+
I never escape in and out of php and html except a few rare times.