How to concat string with PHP The concat string and variable can using (. dot) Or input as variable under ” ” (double quote)
ShotDev Focus:
- Concat string and variable
Example
concat.php
<? $myVar1 = "Weerachai"; $myVar2 = "Nukitram"; $myConcat1 = $myVar1.$myVar2; $myConcat2 = "$myVar1 $myVar2"; $myConcat3 = '$myVar1 $myVar2'; echo "myConcat1 = ".$myConcat1; echo "<br>"; echo "myConcat2 = ".$myConcat2; echo "<br>"; echo "myConcat3 = ".$myConcat3; ?>
Create a php file and save to path root-path/myphp/concat.php
Run
http://localhost/myphp/concat.php
Screenshot