The out put of the above command will give the full sentence
$string1="Welcome to plus2net.com"; $string2=" PHP section "; $string=$string1.$string2; echo $string;
We can add any number of strings by using " . " ( dot ) in between them.
Welcome to plus2net.com PHP section
The above code will print all the strings one after other forming the complete sentence.
$string= " Hello, "; $string .=" Welcome to "; $string .=" plus2net.com "; echo $string;
Here the code will display full string with string2 value added at the end. But this way we can't add function inside a string. Let us try to add one function to display present date inside the welcome message. Here like a string we can't add. The following line won't display today's date along with the string. This is not going to work .
$string2=" PHP section "; $string= "Welcome to plus2net.com $string2"; echo $string;
We have to modify the above line like this to display current date.
$string= "Welcome to plus2net.com $string2 today on date('m/d/y')”;
Output is here
$string= "Welcome to plus2net.com $string2 today on ". date("m/d/y"); echo $string;
Welcome to plus2net.com PHP section today on 10/03/23
|Good useful article.|