elibraryportal Logo

Echo and Print Statement in PHP

In PHP there are two ways to get output:

  1. Echo Statement.
  2. Print Statement.

1) PHP Echo Statement

  1. Echo statement can display anything on the browser, such as string, numbers, variables values etc. or You can say the echo statement can output one or more strings.
  2. echo has no return value .
  3. echo statement can be used with or without parentheses: echo or echo().

Example :-

Output

This is Job Portal Website
rojgarbharat.info
5

2) PHP Print Statement

  1. Print statement can display anything on the browser, such as string, numbers, variables values etc
  2. print has a return value of 1 so it can be used in expressions.
  3. print statement can be used with or without parentheses: print or print().

Example :-

Output

rojgarbharat.info!
123456789
Red
Next Topic