PHP Echo Function


 

PHP Echo Function

As you know echo () is one of the function of php, which is used to show the single or multiple strings on the browser.

As you know echo () is one of the function of php, which is used to show the single or multiple strings on the browser.

PHP Echo Function

As you know echo () is one of the function of php, which is used to show the single or multiple strings on the browser. You can write the echo function as given below…
<php
Echo “hi how are you doing?”;
?>
And once you run it…you will get following output on the web page:

hi how are you doing?

There is more way that can be used for example … you can declare a variable and assign the value to it. And just write “echo $variablename;

PHP Echo Function Example:
<php
$value = “Hi, How are you?”;
echo $value;
?>

This will do the same job… output of the example would be

Hi, How are you?

If we compare the foregoing examples there is one difference… as I have used double quotes around the set of sting in the first example but not in the second one. But both the ways are correct and showing the projected output.

You can also notice one more thing here… as we have said echo is a function that means we must use parentheses ( ) around it but we are not doing the same.  As in actual php function is not a function in actual. So, it’s not required to use ( ) around the echo ..it will work without it as well.

To understand the PHP echo function more in details… I am showing you one more example that will illustrate how to concatenate the variable and your set of string in the same echo command. Let’s see the example below…

<?php

$value = "Hello";

echo $value. "India!";

?>

The output of this example will be …

Hello India!
As we have joined the value of variable and our set of string with the help of concatenating operator, it is showing “Hello India!” as output.  Please remember that “.” is a concatenating operator. That means it’s used to join the different values.
 

Ads