web 2.0

How to concat string/variable with PHP

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

PHP Concat String

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.