在标题中添加逗号(php)

I want to comma separate last name and first name in the result. How can I do this? I tried:

$headers .= 'From:'.$gender.''.$last_name.','.$first_name.'<'.$email.'>' . "
".

but this does not work.

When I use:

$headers .= 'From:'.$gender.''.$last_name.''.$first_name.'<'.$email.'>' . "
".

it does work, but no comma is added.

Can anyone help please?

Change the simple quotes to double quotes, so you can get the text as you are searching

$headers .= "From: $gender $last_name, $first_name <$email>
";

More info: https://stackoverflow.com/a/3446286/5586647