Roger Rosentreter
Roger Rosentreter

Reputation: 17

Joining two variable with a space between

I have two variables, $firstname & $lastname

I want to combine them as another variable $realname

So example: if firstname=John &lastname=Smith, then I want realname=John Smith

Would this be the correct usage?

$realname = $firstname & " " & $lastname;
?>

Upvotes: 0

Views: 236

Answers (1)

Shoyeb Sheikh
Shoyeb Sheikh

Reputation: 2866

<?php   
    $realname = "$firstname $lastname";
?>

Concatenation in php is achieved by concat operator i.e .

Upvotes: 1

Related Questions