What are the potential pitfalls of using absolute paths versus server paths when creating directories in PHP?

Using absolute paths in PHP can cause issues when moving the code to a different server or environment, as the absolute path may not be valid in the new location. It's recommended to use server paths, which are relative to the server root directory and remain consistent across different environments.

// Using server paths to create directories in PHP
$directory = $_SERVER['DOCUMENT_ROOT'] . '/new_directory';
if (!is_dir($directory)) {
    mkdir($directory);
}