print

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!

addcslashes

addslashes

bin2hex

chop

chr

chunk_split

convert_uudecode

convert_uuencode

count_chars

crc32

crypt

echo

explode

fprintf

get_html_translation_table

hebrev

hebrevc

hex2bin

html_entity_decode

htmlentities

htmlspecialchars

htmlspecialchars_decode

implode

join

lcfirst

levenshtein

localeconv

ltrim

md5

md5_file

metaphone

nl_langinfo

nl2br

number_format

ord

parse_str

printf

quoted_printable_decode

quoted_printable_encode

quotemeta

rtrim

setlocale

sha1

sha1_file

similar_text

soundex

sprintf

sscanf

str_contains

str_ends_with

str_getcsv

str_ireplace

str_pad

str_repeat

str_replace

str_rot13

str_shuffle

str_split

str_starts_with

str_word_count

strcasecmp

strchr

strcmp

strcoll

strcspn

strip_tags

stripcslashes

stripos

stripslashes

stristr

strlen

strnatcasecmp

strnatcmp

strncasecmp

strncmp

strpbrk

strpos

strrchr

strrev

strripos

strrpos

strspn

strstr

strtok

strtolower

strtoupper

strtr

substr

substr_compare

substr_count

substr_replace

trim

ucfirst

ucwords

vfprintf

vprintf

vsprintf

wordwrap

PHP

Home Menu