PHP » I/O » print

int print(string s)
String to be printed.

Sends text to the web browser.

print is the most commonly used function to send output to the web browser. It is not a normal function, but a language construct, and does not require the use of parentheses. When using these output functions, it is useful to know how strings are escaped and evaluated. For more information about this, see the Strings section.

A short way of sending output is to use the form: <?=$var?>. This is very useful when mainly writing html code outside PHP tags, but some values from variables are still needed.



$date = date("l");

print "Hello world<br>";
print "Today is $date<br>";


Hello world
Today is Saturday


This example shows how print() can be used to output text and variables. It also demonstrates how the values of variables can be inserted into html code.

See Also: