Search

PHP echo And print

There are two basic ways to get output echo and print. we use echo or print in almost every string value example. So, this chapter contains a little more info about those two output statements.

  • The echo print statement can output one or more strings.
  • The echo print statement can display anything that can be displayed to the browser
  • The echo statement can be used without Or with parentheses : echo or echo().
  • The echo is marginally faster than print

Small differences echo And Print Statement 

echo has no return value while print has a return value of 1 so it can be used in expressions.

Syntax

//echo syntax 
echo $var;
//print syntax 
print($var);

The PHP echo Statement

The echo statement can be used without Or with parentheses : echo or echo().

Example

//echo without parentheses 
echo $var;
//echo with parentheses
echo($var);

The PHP print Statement

The print statement can be used without Or with parentheses : print or print().

Example

//print without parentheses 
print$var;
//print with parentheses
print($var);

Stack Overlode is optimized Tutorials and examples for learning and training. Examples might be simplified to improve reading and learning and understand. Tutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using Stack Overlode, you agree to have read and accepted our terms of use, cookie and privacy policy.