How can the relative paths in require_once() and include() statements cause issues in PHP projects?

Relative paths in require_once() and include() statements can cause issues in PHP projects when the script is executed from different directories, leading to file not found errors. To solve this issue, it's recommended to use absolute paths or define a constant for the base directory of the project and concatenate it with the relative path.

define('BASE_PATH', dirname(__FILE__));

require_once(BASE_PATH . '/includes/config.php');
include(BASE_PATH . '/includes/functions.php');