Output a string
print is a language construct, not a function, so parentheses are not required.
Syntax
print ( string $arg ) : int
Parameters
arg
The input data.
Return
Returns 1, always.
Examples
1
<? $arg = "Hello World!"; print($arg); ?>
Hello World!
2
<? $arg = "without parentheses"; print $arg; ?>
without parentheses
3
<? $arg = "spans multiple lines - newlines are also output"; print $arg; ?>
spans multiple lines - newlines are also output
4
<? $arg = "spans\nmultiple lines - newlines\nare also\noutput"; print $arg; ?>
spans multiple lines - newlines are also output
5
<? $arg = "escaping characters: \"like this\""; print $arg; ?>
escaping characters: "like this"
6
<? $var = "variable"; $arg = "variable with double quotes: $var"; print $arg; ?>
variable with double quotes: variable
7
<? $var = "variable"; $arg = 'variable with single quotes: $var'; print $arg; ?>
variable with single quotes: $var
8
<? $array = array("key" => "value"); $arg = "array: {$array['key']}"; print $arg; ?>
array: value
9
<? $var = "variable"; print <<<END This uses the "here document" syntax to output multiple lines with $var interpolation. Note that the "here document" terminator must appear on a line with just a semicolon no extra whitespace! END; ?>
This uses the "here document" syntax to output multiple lines with variable interpolation. Note that the "here document" terminator must appear on a line with just a semicolon no extra whitespace!