Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Echo Statement, Print Statement, and Here document in PHP.

Echo Statement

This statement is used to output the data to the screen or printing text on the screen. For Example:-
echo “Sushant Kumar”;
echo ‘Sushant Kumar’;
echo 59.236;
echo (“Sushant Kumar”);
echo “Sushant” , “Kumar”;
echo “Sushant” . “Kumar”;

Note- We use both (,) and (.) for concate.

echo with HTML

You can use HTML tags with echo statement and tags should be written under double quote(“Example”). For Example:-

Output: Sushant Kumar

echo with Variable

You can also use echo with a variable to print the value of the variable. For Example:-
$value1 = 10
to print the value of variable value1 we write,
echo $value1;

then, it prints the value,

Output:- 10

We can also display both text and variable value at once, see below
Here Variable is

$name = “Sushant”;
echo “I am ” , $name;

Output: I am Sushant

If you want to use HTML tags in Variable then, see the below example

It Display’s name in Bold,

Output:- Sushant

Note:- 1. The text should be enclosed with quotes. 2. HTML tags should be enclosed with quotes.

Print Statement

This is very similar to the echo statement, a way of displaying text. For Example:-

Output: Sushant Kumar

Similarly, if you want to display text and variable both, then see the below example:-

Output: Hello, I am Sushant Kumar

Difference Between print and echo.

  1. echo has no return value while print is more like PHP function so it returns a value, which is always set to 1.
  2. echo can take multiple parameters while print can take only one.
  3. echo is marginally faster than print.

Here document in PHP

PHP here document is another way of displaying text. a here document(heredoc) is just some text inserted directly in a PHP page.

Syntax:-

For Example:-

Output:-
Hello
I am sushant kumar
I am A boy

Click Here For Next Part – What are Comments, Constant Variable, String Interpolation, Arithmetic and Assignment Operators in PHP?

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

What is CodeIgniter and use cases of CodeIgniter?

What is CodeIgniter? CodeIgniter is an open-source PHP web application framework designed to simplify and accelerate web development. It follows the Model-View-Controller (MVC) architectural pattern and provides…

Read More

What is PHP and use cases of PHP?

What is PHP? Are you wondering what PHP is and how it works? Look no further! In this article, we will explore the ins and outs of…

Read More

Complete guide on PHP certification courses, tutorials & training

What is PHP Hypertext Preprocessor is known as PHP. Many developers use PHP, an open-source server-side programming language, to create websites. In addition, it is a general-purpose…

Read More

Complete PHP with Laravel Certification Guide & tutorials

What is PHP with Laravel? PHP was visioned eventually in the fall of 1994 by Rasmus Lerdorf. PHP means Hypertext Preprocessor. It’s a extensively- used, open source…

Read More

Top 50 PHP Interview Questions and Answers

1) What is PHP? PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development….

Read More

Complete guide of PHP certification courses, tutorials & training

PHP is a great beginner programming language for anyone who is wanting to cross over into the coding world. Though easy to learn, it is an extremely…

Read More