Have an account? Sign in
Login  Register  Facebook
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
Quick Table of Contents
  • print() — statement outputs data passed to it
  • echo() — statement for the same purposes as print()
  • printf() — output a blend of static text and dynamic information
  • sprintf() — identical to printf() except that the output is assigned to a string
[Edit] The print() Statement
The print() statement outputs data passed to it . Its prototype looks like this:
int print(argument)
All of the following are plausible print() statements:
<?php
print("<p>Hello World</p>");
?>
<?php
$season = "summertime";
print "<p>I love the $season.</p>";
?>
All these statements produce identical output:
I love the summertime.
Note Although the official syntax calls for the use of parentheses to enclose the argument, they’re not required because print() isn’t technically a function; it’s a language construct. Many programmers tend to forgo them simply because the target argument is equally apparent without them. The print() statement’s return value is misleading because it will always return 1 regardless of outcome (the only outcome I’ve ever experienced using this statement is one in which the desired output is sent to the browser). This differs from the behavior of most other functions in the sense that their return value often serves as an indicator of whether the function executed as intended.
September 1, 2011