What are the best practices for handling file names and paths in PHP scripts when dealing with changing file naming conventions?

When dealing with changing file naming conventions in PHP scripts, it is best to use a configuration file or database to store the file naming conventions. This way, you can easily update the naming conventions in one central location without having to modify multiple scripts. Additionally, using PHP's built-in functions like `basename()` and `dirname()` can help handle file paths dynamically.

// Define file naming conventions in a configuration file or database
$fileNamingConventions = [
    'image' => 'image_',
    'document' => 'doc_'
];

// Example usage to construct file paths dynamically
$fileType = 'image';
$fileName = $fileNamingConventions[$fileType] . '1.jpg';
$filePath = '/path/to/files/' . $fileName;

echo $filePath;