Member Avatar for Aardwolf

How would I do this in 1 line

$name = $firstName + " " + $lastName;
//output: 0

the problem is what I think it is, is that its trying to add like mathematics.
whilst I want the '+ " " +' to become a space in between the firstname and lastname variables.

Recommended Answers

All 3 Replies

You could do:

$name = $firstName . ' ' . $lastName;
$name = "{$firstName} {$lastName}";
$name = "$firstName $lastName";

R.

commented: Really good work man -Voltimolt +0
Member Avatar for Aardwolf

Oh thank you :)

Mark as solved if your problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.