Showing posts with label concatenation. Show all posts
Showing posts with label concatenation. Show all posts

Wednesday, April 18, 2012

Using Concatenation Operator

Now we are talking about Concatenation.
Concatenation operator (.) [dot] is use to put two string value together.
To concatenate two string value together, use the concatenation operator.      

++++++++++++++++++
<?php
$string1="Hello";
$string2="Welcome to Mint PHP !";
echo $string1. " " .$string2;
?>
++++++++++++++++++
Output:
___________

Hello Welcome to Mint PHP !
______________

There is another method, without using the   .= operator  by this we can join different variable into another variable.
Example:
++++++++++++++++


   <?php
$string1="Hello,";
$string2="World!";
$string3=$string1 . $string2; 
$string4=$string1 . ' and welcome to Mint PHP Blog ' .$string2;

echo $string3.' ' .$string4;

?>

++++++++++++++
Output:
_______

Hello,World! Hello, and welcome to Mint PHP Blog World!
_____________

Saturday, February 18, 2012

Outputting A String

Thank you for reading my Blog.
We have done in previous lesson use PHP " echo " .we can also use the "ptint" function as like as C programming.
You can place either a string variable or you can use quotes,like i do below, to create a string that the echo/print function will output.

**************************************
<body>
<?php
$myString="Hello ! Welcome to Mint PHP ";
echo $myString."<br/>";
echo 'I love PHP :)'."<br/>";
print "You can also use print as like as \"echo\".";
?>