What are the best practices for handling file paths and includes in PHP scripts that need to be executed both via cron jobs and manual browser access?

When dealing with file paths and includes in PHP scripts that need to be executed both via cron jobs and manual browser access, it's important to use relative paths instead of absolute paths. This ensures that the script can be run consistently regardless of the context in which it is executed. Additionally, using the `__DIR__` magic constant can help to establish a reliable base path for includes.

// Define base path for includes
define('BASE_PATH', __DIR__);

// Include files using relative paths
require_once BASE_PATH . '/includes/config.php';
require_once BASE_PATH . '/includes/functions.php';