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 / suresh.chaluvadi

when u use print(),a value of 1 or 0 will be returned upon
success or failure of the the print command.where as echo()
just does what its told without letting u know whether or
not it worked properly.

Is This Answer Correct ?    126 Yes 13 No

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

Answer / guest

Print() can't be accept multipale argument but echo() can
be.

Is This Answer Correct ?    97 Yes 17 No

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

Answer / nikunj

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 ?    83 Yes 10 No

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

Answer / sreedevi

print is a construct but it returns True on success
outputr False if it was unable to print the output string
echo is faster comparing with print .
print doesnot takes multiple parameters

Is This Answer Correct ?    31 Yes 8 No

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

Answer / binoyav

In answer #10 the following section is wrong
"
echo evaluate the string before send the output just like this
$a=10
echo "Value is $a"
output:- Value is 10

print 'Value is $a'
output:- Value is $a "

If we give double quotes instead of single quote this will work.

Is This Answer Correct ?    17 Yes 5 No

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

Answer / rajesh kumar vishwakarma

echo() is not actually a function (it is a language
construct) so you are not required to use parentheses with
it. In fact, if you want to pass more than one parameter to
echo, you must not enclose the parameters within parentheses.

print() is not actually a real function (it is a language
construct) so you are not required to use parentheses with
its argument list.

1. Speed. There is a difference between the two, but
speed-wise it
should be irrelevant which one you use. echo is marginally
faster
since
it doesn't set a return value if you really want to get down
to the
nitty gritty.

2. Expression. print() behaves like a function in that you
can do:
$ret = print "Hello World"; And $ret will be 1. That means
that print
can be used as part of a more complex expression where echo
cannot. An
example from the PHP Manual:

$b ? print "true" : print "false";

print is also part of the precedence table which it needs to
be if it
is
to be used within a complex expression. It is just about at
the bottom
of the precedence list though. Only "," AND, OR and XOR are
lower.

3. Parameter(s). The grammar is: echo expression [,
expression[,
expression] ... ] But echo ( expression, expression ) is not
valid.
This would be valid: echo ("howdy"),("partner"); the same
as: echo
"howdy","partner"; (Putting the brackets in that simple
example
serves
no purpose since there is no operator precedence issue with
a single
term like that.)

So, echo without parentheses can take multiple parameters,
which get
concatenated:

echo "and a ", 1, 2, 3; // comma-separated without
parentheses
echo ("and a 123"); // just one parameter with
parentheses

print() can only take one parameter:

print ("and a 123");
print "and a 123";

Is This Answer Correct ?    9 Yes 0 No

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

Answer / mink$

every thing in single quotes is treated as string and would
not be evaluated in either print or echo.

Is This Answer Correct ?    12 Yes 4 No

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

Answer / muhammad ali kazi

Echo() and Print() Outputs string Echo() is statement and
Print() is functions.

Is This Answer Correct ?    22 Yes 16 No

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

Answer / ramesh kumar jayaraman

In Php echo is a statement..it doesn't return any
value...And It is faster
because it does not return any value, but print which
always returns 1 and 0.

The print acts like a function and it can be used in complex
expressions.

but echo can not be used in this way.

Is This Answer Correct ?    7 Yes 1 No

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

Answer / ajeet singh

Ajeet: echo can take multiple expressions but print can take
only one

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More PHP Interview Questions

How is session id stored in browser?

0 Answers  


Write a program to get second highest number in an array using php?

0 Answers  


What is alias in php?

0 Answers  


Which is true about the singleton design pattern?

0 Answers  


How to convert a json string to an array in php?

0 Answers  


How long should a session last?

0 Answers  


Difference between $message vs. $$Message in php.

0 Answers  


How to declare an array in php?

0 Answers  


"$this" what type of object it is?

2 Answers  


What is the purpose of the php empty function?

0 Answers  


Write down the code for save an uploaded file in php.

0 Answers  


Whether site will complete the execution of the script if Fatal error occurs ?

1 Answers  


Categories