FANDOM


The title of this article should be print(), but due to technical restrictions, cannot contain parenthesis.

Outputs a string.

print() is not actually a function, but rather a language construct so the parenthesis are not actually required, even when passing more than one argument to it for output.

While print() and echo() are nearly identical in their functionality, there is a small difference. print() behaves more like a function and does allow for additional functionality because of it. See Example 3 below for a sample of this functionality.

Arguments Edit

void print ({{{params}}})

Argument Inclusion Edit

(PHP 3, PHP 4, PHP 5)

Examples Edit

Example 1: Edit

<?php
$foo = "is";
$bar = "output";
print "This $foo sample $bar!";
?>

Output Edit

This is sample output!

Example 2: Edit

<?php
print "In this sample
      Newlines will be displayed
      as well.";
?>

Output Edit

In this sameple
Newlines will be displayed
as well.

Example 3: Edit

<?php
$foo = print "This is sample output!/n"; // echo() cannot be used here
print $foo; // $foo will return a value of 1
?>

Output Edit

This is sample output!
1
For more details on this function, visit its entry in the php manual.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.