For printing out strings, there are echo, print and printf.
Explain the differences.

Answers were Sorted based on User's Feedback



For printing out strings, there are echo, print and printf. Explain the differences...

Answer / coder

echo is a language construct(You can see we don't use
paranthesis for echo).echo does not return any value. print
is also a language construct but it returns an integer
value. printf is a function..... echo is considered fast
than print

Is This Answer Correct ?    7 Yes 0 No

For printing out strings, there are echo, print and printf. Explain the differences...

Answer / hardik

echo is a language construct(You can see we don't use
paranthesis for echo).echo does not return any value. print
is also a language construct but it returns an integer
value. printf is a function..... echo is considered fast
than print and printf

Is This Answer Correct ?    4 Yes 0 No

For printing out strings, there are echo, print and printf. Explain the differences...

Answer / shilpa yogesh agrawal

echo, print and printf are used for printing strings but the
basic difference between them is: echo is the most primitive
of them, and just outputs the contents following the
construct to the screen. print is also a construct (so
parentheses are optional when calling it), but it returns
TRUE on successful output and FALSE if it was unable to
print out the string. And you can pass multiple parameters
to echo, like:

and it will output the string “Welcome Jack”

Whereas print does not take 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.

printf� is a function, not a construct, and allows such
advantages as formatted output, but it’s the slowest way to
print out data out of echo, print and printf.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More PHP Interview Questions

Would you initialize your strings with single quotes or double quotes?

4 Answers  


How can we display the output directly to the browser?

0 Answers  


What is a query in php?

0 Answers  


Can I run php without xampp?

0 Answers  


What is the difference between the functions unlink and unset?

6 Answers  






how to store case sensitive data in mysql ? how repair mysql table? diff bet float, double,real? diff bet mysql_fetch_object() and mysql_fetch_array()? which version of mysql support procedure , trigger? diff php4 and php 5? op - 2+5+"8"=? how to create object in javascript? query - select games from team who won games 2/4/6? NaN command in php? How to offload System date in mysql? typecasting in php? how to convert string to two decimal no? how to parse xml file in php command line argument in php? diff bet $msg,$$msg? diff bet require(), include(), include_once()? tables in mysql?

2 Answers   Aloha Technology,


How to get the http request in php?

0 Answers  


How to generate a character from an ascii value?

0 Answers  


What is the most convenient hashing method to be used to hash passwords?

0 Answers  


How to Calculate Internal links & External Link in Website.(For Example YAHOO WEBSITE)

1 Answers  


List out different arguments in PHP header function?

4 Answers  


How arrays are used in php?

0 Answers  


Categories