How can absolute paths be used effectively in PHP scripts to avoid potential errors related to working directories?

Absolute paths can be used effectively in PHP scripts to avoid potential errors related to working directories by providing the full path to files or directories regardless of the script's current working directory. This ensures that the script can always locate the necessary resources even if it is executed from different directories.

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