PHP print() Function
Complete PHP String Reference
Definition and Usage
The print() function outputs one or more strings.
Syntax
| Parameter |
Description |
| strings |
Required. One or more strings to be sent to the output |
Tips and Notes
Note: The print() function is not
actually a function, so you are not required to use parentheses with it.
Tip: The print() function is
slightly slower than echo().
Example 1
<?php
$str = "Who's Kai Jim?";
print $str;
print "<br />";
print $str."<br />I don't know!";
?>
|
The output of the code above will be:
Who's Kai Jim?
Who's Kai Jim?
I don't know!
|
Example 2
<?php
print "This text
spans multiple
lines.";
?>
|
The output of the code above will be:
|
This text spans multiple lines.
|
Example 3
Difference of single and double quotes. Single quotes will print the variable
name, not the value:
<?php
$color = "red";
print "Roses are $color";
print "<br />";
print 'Roses are $color';
?>
|
The output of the code above will be:
Roses are red
Roses are $color
|
Complete PHP String Reference

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|