Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP print() Function

PHP print() Function

PHP String Reference Manual PHP String Reference Manual

Example

Output some text:

Run Example »


Definition and Usage

The print() function outputs one or more strings.

**Note:** The print() function is not actually a function, so you do not need to use parentheses with it.

**Tip:** The print() function is slightly slower than echo() .


Syntax

print(

strings

)

Parameters Description
strings Required. One or more strings to send to the output.

Technical Details

Return Value: Always returns 1.
PHP Version: 4+

More examples

Example 1

Output the value of the string variable ($str):

Run Example »

Example 2

Output the value of the string variable ($str), including HTML tags:

What a nice day!"; ?>

Run Example »

Example 3

Concatenate two string variables:

Run Example »

Example 4

Output the values of an array:

"35"); print "Peter is " . $age['Peter'] . " years old."; ?>

Run Example »

Example 5

Output some text:

Run Example »

Example 6

The difference between single and double quotes. Single quotes output the variable name, not the value::

"; print 'Roses are $color'; ?>

Run Example »


PHP String Reference Manual PHP String Reference Manual