What are some common pitfalls when linking PHP pages within a website?
One common pitfall when linking PHP pages within a website is not using the correct file path or URL, which can result in broken links. To avoid this issue, it's important to use relative paths or dynamic methods to generate links, rather than hardcoding them.
// Incorrect way to link to another PHP page
<a href="page2.php">Page 2</a>
// Correct way using a relative path
<a href="page2.php">Page 2</a>
// Correct way using PHP to generate dynamic links
<a href="<?php echo 'page2.php'; ?>">Page 2</a>