How can relative path references be utilized effectively in PHP for including images or other resources within a script?

Relative path references can be utilized effectively in PHP by using the `dirname(__FILE__)` function to get the current directory of the script and then appending the relative path to the desired resource. This ensures that the resource can be included regardless of the script's location in the file system.

<?php
// Get the current directory of the script
$currentDirectory = dirname(__FILE__);

// Define the relative path to the image or resource
$imagePath = $currentDirectory . '/images/example.jpg';

// Include the image using the relative path
echo '<img src="' . $imagePath . '" alt="Example Image">';
?>