You can run the two variables in echo statement by declaring the concatenation tag.
Here is the example:
[php]<?php
$name="John";
$lastName="Graham";
echo $name." ".$lastName; // Outputs John Grahem
?>[/php]
Let’s break down the code to understand each element.
1) We have created the simple php code by using variable “$name
” & “$lastName
” to assign the string value “John
” & “Graham
” respectively.
[php]<?php
$name="John";
$lastName="Graham";
?>[/php]
2) Now we run the code by declaring the concatenation tag in the echo statement.
[php]<?php
$name="John";
$lastName="Graham";
echo $name." ".$lastName; // Outputs John Graham
?>[/php]
3) The concatenation tag looks like this.
[php]." ".[/php]
By declaring the concatenation tag you can separate the two variables.
4) The php code will run smoothly once you add concatenation tag in between the variables and execute the code.
The above code will give output.
John Graham