Bird
0
0

What is the main difference between print and echo in PHP?

easy📝 Conceptual Q1 of 15
PHP - Output and String Handling
What is the main difference between print and echo in PHP?
ABoth return values but <code>print</code> is faster
B<code>print</code> returns a value, <code>echo</code> does not
C<code>echo</code> returns a value, <code>print</code> does not
DThere is no difference; they are exactly the same
Step-by-Step Solution
Solution:
  1. Step 1: Understand print behavior

    print returns 1 after printing the string, so it can be used in expressions.
  2. Step 2: Understand echo behavior

    echo outputs strings but does not return any value.
  3. Final Answer:

    print returns a value, echo does not -> Option B
  4. Quick Check:

    print returns 1 = C [OK]
Quick Trick: Remember: print returns 1, echo does not return [OK]
Common Mistakes:
  • Thinking echo returns a value
  • Assuming both behave identically
  • Confusing speed differences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes