print

int print(mixed value) 

Sends a value to stdout.

Returns:

1 on success; nothing on failure

Description:

print is a language construct that converts a value to a string and sends it to standard output. Standard output is usually a browser or command interpreter (a.k.a. shell/DOS window).

Placing parentheses () around the argument to print is optional; for example, print "Hi!"; works quite nicely without parentheses.

Version:

PHP 3+, PHP 4+

See also:

To send a string to stdout:

echo() 
printf() 

Example:

Display some values
<?php 
print "Hello Joe!\n"; 
print ("What is your favorite color?'."\n"; 
print 200; 
print ("\n" . sqrt (100)); 
?> 

Output: 
Hello Joe! 
What is your favorite color? 
200 
10 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.