What is the Diff. Between echo() and Print() in PHP?

Answers were Sorted based on User's Feedback



What is the Diff. Between echo() and Print() in PHP?..

Answer / krupa

echo and print are different

Is This Answer Correct ?    7 Yes 2 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / satish

echo is language construct. print is function. echo is
faster. langauge constructs are faster than functions,
always. echo may tek mutiple arguments as well. echo
doesn't give return value.

Is This Answer Correct ?    6 Yes 2 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / arvind pippal

echo is the multiple funtion,print does not multiple
parameters. It is also generally argued that echo is
faster, but usually the speed advantage is negligible, and
might not be there for future versions of PHP.
advantages as formatted output, but it’s the slowest way to
print out data out of echo, print.

Is This Answer Correct ?    13 Yes 10 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / nidz

echo and print both are not functions but a
construct...print can be used as function ...Can anybody
tell me what is construct ?

Is This Answer Correct ?    8 Yes 5 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / pushp

Echo has slight performance advantage because it does not
return value.

Is This Answer Correct ?    7 Yes 4 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / rajiv_cogzidel

echo() doesn't return anything. But print() return true or
false.
You can give output for print() using echo(). You can notice
here print having true. So it give output 1.
Because print is a function. So it return true or false. But
echo is an statement. So it will not.
Ex:-
echo(print(d));
Output:-
d1

But you can't do this using print like this

Ex:-
print(echo(d));

Output:-
Parse error: syntax error, unexpected T_ECHO in
E:\xampp\htdocs\rajiv\valid.php on line 119


And other thing is echo() allow multiple strings using
separated by comma(,).
Here are examples

using echo()
ex:-
echo "Rajiv","\n","K.C","\n","\nHello World!","\nAgain Hello
World!";

output:-
Rajiv K.C Hello World! Again Hello World!

using print()
ex:-
print "Rajiv","\n","K.C","\n","\nHello World!","\nAgain
Hello World!";

output:-
Parse error: syntax error, unexpected ',' in
E:\xampp\htdocs\rajiv\valid.php on line 130

Some one says we cannot use double quotes in single quote.
But it's not true. It will work. Here are examples

print 'print"hai"hoo';
echo 'echo"hai"hoo';

These two give output.

Is This Answer Correct ?    4 Yes 1 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / vinay sachan

There are many differences in print() and echo() :-

1-echo is unformatted whereas print is formatted.

2-echo() can take multiple expressions, Print cannot take multiple expressions.
ex.-
<?php
$name="Vinay";
echo "Name is $name";
//Value is Vinay

print 'Name is $name';
//Value is $name
?>

3-Print return true or false based on success or failure whereas echo just does what its told without letting you know whether or not it worked properly.

Is This Answer Correct ?    3 Yes 0 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / surendra.kandimalla

Echo:echo as a function we can pass only one argument.But echo as command we can pass any number of arguments.echo will not return anything.
echo("echo as function<br>");
echo"arg1","arg2","arg3","<br>";

Print:we can pass only one argument for print as function or command.print returns boolean value.
print("print function<br>");
$b=print"print command<br>";
echo $b,"<br>";

Is This Answer Correct ?    1 Yes 0 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / kunal

print() is a function but echo is statement

Is This Answer Correct ?    57 Yes 57 No

What is the Diff. Between echo() and Print() in PHP?..

Answer / kroonal

echo() have multiple arguments whereas print() have one
arguments. echo() have not any return value whereas print()
return 0 or 1 as per success

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

what are the differences between php and perl

0 Answers   TCS,


Whether One-line comment begin with pound sing(#) in php?

2 Answers  


Distinguish between urlencode and urldecode?

0 Answers  


How can we access the data sent through the url with the get method?

0 Answers  


What are hooks in php?

0 Answers  






How do you display the output directly to the browser?

0 Answers  


How many types of php frameworks are there?

0 Answers  


What is a base url?

0 Answers  


when you will get the message/error "headers already sent"?

5 Answers  


What is the use of strip_tags() method?

0 Answers  


How come the code works, but does not for two-dimensional array of mine?

0 Answers  


Explain what is the difference between mysql_fetch_array() and mysql_fetch_assoc()?

0 Answers  


Categories