xoxox xoxox - 1 month ago 8
PHP Question

How can I insert a value into a string without concatenation?

My goal is to insert a variable's value directly into a string without concatenation using the

.
operator.

I tried like this:

$filename = 'some_file_name';
header('Content-disposition: attachment; filename=$filename');


But this gives me
filename=$filename
, not
filename=some_file_name
.

How do I achieve this? What am I missing?

Answer
$filename = "path/to/file.txt";
header("Content-disposition: attachment; filename=$filename");