How can you dynamically reference file paths in PHP without using absolute paths?

When referencing file paths in PHP, using absolute paths can be problematic as they may vary between different servers or environments. To dynamically reference file paths without using absolute paths, you can use the `__DIR__` magic constant to get the current directory of the file and then concatenate it with the relative path to the desired file.

// Dynamically reference file paths without using absolute paths
$relativePath = 'folder/file.txt';
$absolutePath = __DIR__ . '/' . $relativePath;

// Use $absolutePath to access the file
echo file_get_contents($absolutePath);