What is echo and print in PHP

Hello Friend how are you i hope you all are doing well. Today in this post we will learn Echo and Print, How to use echo and print in PHP. If you are learning PHP then this post will be very useful for you because in this post you will get the complete knowledge of variables in PHP.

Let's Start 

👉Program in PHP using echo

<?php
echo "Hello World";
?>

1.echo is used to display the text on to the output screen.
2.It can be used with parentheses or without parentheses.

<?php
echo "Hello World<br>";
echo ("Hello World<br>");
?>
#output
Hello World
Hello World

3.It can also print multiple string separated by comma simultaneously.

<?php
echo "Hello ","friends ";
?>
#output
Hello friends

4.It does not return any value.
5.echo is not case sensitive.

<?php
echo "Hello World<br>";
ECHO "Hello World<br>";
Echo "Hello World";
?>
//output
Hello World
Hello World
Hello World

👉Program in PHP using print

<?php
print "Hello World";
?>

1.print is also used to display the text on to the output screen.
2.It can be used with parentheses or without parentheses.

<?php
print "Hello World<br>";
print ("Hello World<br>");
?>
#output
Hello World
Hello World

3.It can not print multiple string simultaneously.
4.It has a return value of 1.
5.print is also not case sensitive.

<?php
print "Hello World<br>";
PRINT "Hello World<br>";
Print "Hello World";
?>
//output
Hello World
Hello World
Hello World

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 

Thanks.

Post a Comment

0 Comments