How can absolute paths be used effectively in PHP scripts to avoid issues with file directories?

When using relative paths in PHP scripts, issues can arise when the script is executed from different directories, leading to incorrect file paths. To avoid these problems, absolute paths can be used instead. Absolute paths specify the full path to a file or directory on the server, ensuring that the script can always locate the correct file regardless of the current working directory.

// Using absolute path to include a file
include '/var/www/html/includes/config.php';