What are some potential pitfalls when using relative paths in PHP scripts?
When using relative paths in PHP scripts, one potential pitfall is that the path may not resolve correctly depending on the current working directory of the script. To avoid this issue, it is recommended to use the `__DIR__` magic constant to get the absolute path of the current script and then build the relative path from there.
// Get the absolute path of the current script
$currentPath = __DIR__;
// Define the relative path from the current script
$relativePath = 'includes/config.php';
// Combine the absolute path with the relative path
$fullPath = $currentPath . '/' . $relativePath;
// Use the full path in your script
include $fullPath;