What is the common issue when trying to concatenate a variable with a file extension in PHP?
When concatenating a variable with a file extension in PHP, the common issue is that the dot (.) used for concatenation is also the concatenation operator for strings. To solve this issue, you can enclose the variable in curly braces {} to explicitly define the variable name.
// Common issue when concatenating a variable with a file extension
$filename = 'example';
$extension = '.txt';
$fullFilename = $filename . $extension; // This will not concatenate the variable and extension correctly
// Solution to concatenate variable with file extension
$fullFilename = $filename . "{$extension}";
echo $fullFilename; // Output: example.txt