PHP Print

PHP Print Statement

The major differences to echo are that print only accepts a single argument and always returns 1
The print() function used to output one or more string.

  • PHP print is a language construct, so you don’t need to use parenthesis with the argument list. Unlike echo, it always returns 1.
  • PHP print statement can be used to print a string, multi-line strings, escaping characters, variable, array etc.

The syntax of PHP print like as:

PHP print: printing string
File: example1.php

Output:

PHP print: printing multiline string
File: example2.php

Output:

PHP print: printing escaping characters
File: example3.php

Output:

PHP print: printing variable value
File: example4.php

Output:

Resource
PHP.Net