أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
Most of differences already explained in above and below answers. Let me summerize them once again with one or more difference.
Following are few differences between echo and print:
SPEED:
Echo is speed wise faster than Print.
CONSTRUCTs:
Both are constructs but Print behaves like a function and it always returns1 whereas Echo just prints values / strings.
PARAMETERS:
Echo accepts more than1 parameters whereas Print accepts just1 parameter.
TERNARY OPERATION:
Echo can be used in Ternary Operation lik:
echo ( $var ) ? "Yes" : "No";
Print can also be used in Ternary Operation but with a different way like:
( $var ) ? print("Yes") : print("No");
- print only takes one parameter, while echo can have multiple parameters.
- print returns a value (1), so can be used as a function.
- echo is slightly faster.
In daily works i see no difference at all , but you can say their is an acutal diffrence like
Print is a function and always return1
Print take1 param , echo tacks multi, can print multiple strings,variables
echo is faster
There are some differences between echo and print:
In simple words.
Print is a function and always return someing else /1 always.
Echo is just used for display/get output of variable values / string
Print is a function and it will return value, so takes time marginally. Whereas echo is a statement. Using echo we can display one or more strings whereas print will display the output of the string else error.
echo is language construct
echo accepts more than one parameters at a time
where as print only one.
echo is language constructor .
print is function .
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.Expression. print() behaves like a function in that you can do: $ret = print "Hello World"; And $ret will be1. That means that print can be used as part of a more complex expression where echo cannot. An example from the PHP Manual:
in your daily work nothing at all
هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟