PHP » I/O » print

Syntax:
int print(string s)
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.

Examples

Code:
<?php

$date = date("l");

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

?>

<b><center>
<?=$date?>
</b></center>
Output:
Hello world
Today is Saturday

Saturday
Explanation:

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: