Print php variable and string…

Hello Friends, how are you?

I am showing now, how to print variable and string at a time in php? So, consider the below code-

<?php

//this is variable

$name=”Thouhedul Islam Suchi”;

 

echo “Hello, “. $name.”. Thank you for visiting my site.”;

?>

 

Explain:

First I take a variable $name where I put my name. I just want to print this name with other text. Then I make echo statement. After finishing “Hello, ”, I didn’t close my statement by using  ;. After that, I use a . which call concatenation sign for adding with variable and string. Then I put my variable. After putting variable, I put concatenation sign again to add string with variable. Finally I close my echo statement by using ; sign.

 

 

 

Output:

Hello, Thouhedul Islam Suchi. Thank you for visiting my site.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s