What is the correct syntax for replacing a hardcoded value in a file path with a variable in a PHP script?

When working with file paths in PHP scripts, it is often necessary to replace hardcoded values with variables for flexibility and dynamic functionality. To achieve this, you can concatenate the variable with the rest of the file path using the dot (.) operator. This allows you to easily substitute different values for the variable without having to modify the entire file path each time.

// Hardcoded file path
$directory = "/path/to/directory/";

// Variable to replace hardcoded value
$fileName = "example.txt";

// Concatenate variable with file path
$filePath = $directory . $fileName;

// Use the dynamic file path in your code
echo $filePath;