Beginner PHP Tutorial - 10 - print
print <br /> <br />(PHP 4, PHP 5) <br />print — Output a string <br /> <br />Description <br /> <br />int print ( string $arg ) <br />Outputs arg. <br /> <br />print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list. <br /> <br />Parameters <br /> <br />arg <br />The input data. <br /> <br />Return Values <br /> <br />Returns 1, always. <br /> <br />Examples <br /> <br />Example #1 print examples <br /> <br /> "foo"); <br /> <br />print "this is {$bar['value']} !"; // this is foo ! <br /> <br />// Using single quotes will print the variable name, not the value <br />print 'foo is $foo'; // foo is $foo <br /> <br />// If you are not using any other characters, you can just print variables <br />print $foo; // foobar <br /> <br />print <br />Notes <br /> <br />Note: Because this is a language construct and not a function, it cannot be called using variable functions. <br />See Also <br /> <br />echo - Output one or more strings <br />printf() - Output a formatted string <br />flush() - Flush system output buffer <br />Heredoc syntax <br />add a note add a note <br />User Contributed Notes 14 notes <br /> <br />up <br />down <br />22 user at example dot net 7 years ago <br />Be careful when using print. Since print is a language construct and not a function, the parentheses around the argument is not required. <br />In fact, using parentheses can cause confusion with the syntax of a function and SHOULD be omited. <br /> <br />Most would expect the following behavior: <br /> <br /> <br />But since the parenthesis around the argument are not required, they are interpretet as part of the argument. <br />This means that the argument of the first print is <br /> <br /> ("foo") && print("bar") <br /> <br />and the argument of the second print is just <br /> <br /> ("bar") <br /> <br />For the expected behavior of the first example, you need to write: