What are common pitfalls when trying to include images using relative paths in PHP?

Common pitfalls when trying to include images using relative paths in PHP include incorrect file paths and directories, leading to broken image links. To solve this issue, it's important to use the correct relative path to the image file based on the location of the PHP file.

<?php
// Example of including an image using a relative path
$image_path = 'images/example.jpg';
?>

<img src="<?php echo $image_path; ?>" alt="Example Image">