2个变量彼此相邻

I want to input fields for first name and last name, but I also want them to be displayed together, but I can't quite figure out yet how to make the 2 name variables next to eachother! Here's the code I have for this:

$first_name = $poster_data['first_name'];

$last_name = $poster_data['last_name'];

$name = $first_name, $last_name;

Thanks!

$name = "{$first_name}, {$last_name}";
$name = $first_name." ". $last_name;

The extra " " is for a space between the two.

$name = $first_name.', '.$last_name;

It's called string concatenation, and in PHP it's expressed like so, with the . operator:

$name = $first_name . $last_name;

This will print "JohnDoe". If you want to add a space:

$name = $first_name . " " . $last_name;

This will print "John Doe".

To combine strings you use the concatenation operator: ..

$name = $first_name . $last_name;

Though you probably want a space between them:

$name = $first_name . ' ' . $last_name;
echo $firstname . " " . $lastname

to display the name as John Smith