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…
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:
$value = “Hi, How are you?”;
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…
$value = "Hello";
echo $value. "India!";
The output of this example will be …
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.
Recommend the tutorial