Home > Net >  Joining two variable with a space between
Joining two variable with a space between

Time:03-31

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;
?>

CodePudding user response:

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

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

  • Related