How can correct path references be ensured when loading images in PHP from subdirectories?

When loading images in PHP from subdirectories, it is important to ensure that the path references are correct to avoid any errors. One way to do this is by using the `__DIR__` constant to get the absolute path of the current file and then concatenate it with the relative path to the image file.

// Get the absolute path of the current file
$basePath = __DIR__;

// Relative path to the image file
$imagePath = '/images/image.jpg';

// Concatenate the base path with the image path
$fullImagePath = $basePath . $imagePath;

// Output the image using the correct path
echo '<img src="' . $fullImagePath . '" alt="Image">';