Answers for "String Concatenation in PHP"

PHP
2

how to combine variables and text into a string php

<?php
$number = 8;
$txt = "the number is".$number.", ok?"; //Use a dot to combine
echo $txt;
?>
Posted by: Guest on November-01-2020
1

String Concatenation in PHP

phpCopy<?php
$mystring1 = "This is the first string. ";
$mystring2 = "This is the second string. ";
$mystring3 = "This is the third string. ";
$mystring4 = "This is the fourth string. ";
$mystring5 = "This is the fifth string.";

$mystring1 .= $mystring2 .= $mystring3 .= $mystring4 .= $mystring5;
echo($mystring1);
?>
Posted by: Guest on April-23-2021
0

String Concatenation in PHP

phpCopy<?php
$mystring1 = "This is the first string. ";
$mystring2 = "This is the second string";
$finalString = sprintf("%s %s", $mystring1, $mystring2);
echo($finalString);
?>
Posted by: Guest on April-23-2021
0

String Concatenation in PHP

phpCopy<?php
$mystring1 = "This is the first string. ";
$mystring2 = "This is the second string.";
$mystring1 .= $mystring2;
echo($mystring1);
?>
Posted by: Guest on April-23-2021
0

String Concatenation in PHP

phpCopy<?php
$mystring1 = "This is the first string. ";
$mystring2 = "This is the second string. ";
$mystring3 = "This is the third string. ";
$mystring4 = "This is the fourth string. ";
$mystring5 = "This is the fifth string.";

$finalString = $mystring1 . $mystring2 . $mystring3 . $mystring4 . $mystring5;
echo($finalString);
?>
Posted by: Guest on April-23-2021
0

String Concatenation in PHP

phpCopy<?php
$mystring1 = "This is the first string. ";
$mystring2 = "This is the second string.";
$finalString = $mystring1 . $mystring2;
echo($finalString);
?>
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language