Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 is string function sql?

0 Answers  


What are the differences between require and include, include_once?

3 Answers  


What is difference between rest and http?

0 Answers  


Tell me how can we connect to a mysql database from a php script?

0 Answers  


How do I find out the number of parameters passed into function9?

0 Answers  


What is the main difference between require() and require_once()?

0 Answers  


what is the current salary package in India for a PHP programmer who has 1.5 years experience

0 Answers   ABB,


How values in arrays are indexed?

0 Answers  


What is the diffrence between GET,POST and REQUEST Method.

7 Answers   Acquity Software,


How we can declare variable in php?

0 Answers  


How are cookies created?

0 Answers  


What is the use of paypal in the e-commerece website?

3 Answers   RedAlkemi,


Categories