<HTML ><HEAD ><TITLE >print</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="String functions" HREF="ref.strings.html"><LINK REL="PREVIOUS" TITLE="parse_str" HREF="function.parse-str.html"><LINK REL="NEXT" TITLE="printf" HREF="function.printf.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.parse-str.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.printf.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.print" ></A >print</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN90359" ></A ><P > (PHP 3, PHP 4 )</P >print -- Output a string</DIV ><DIV CLASS="refsect1" ><A NAME="AEN90362" ></A ><H2 >Description</H2 ><B CLASS="methodname" >print</B > ( string arg)<BR ></BR ><P > Outputs <TT CLASS="parameter" ><I >arg</I ></TT >. Returns <TT CLASS="constant" ><B >TRUE</B ></TT > on success or <TT CLASS="constant" ><B >FALSE</B ></TT > on failure. </P ><P > <B CLASS="function" >print()</B > is not actually a real function (it is a language construct) so you are not required to use parentheses with it. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN90375" ></A ><P ><B >Example 1. <B CLASS="function" >print()</B > examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php print("Hello World"); print "print() also works without parentheses."; print "This spans multiple lines. The newlines will be output as well"; print "This spans\nmultiple lines. The newlines will be\noutput as well."; print "escaping characters is done \"Like this\"."; // You can use variables inside of an print statement $foo = "foobar"; $bar = "barbaz"; print "foo is $foo"; // foo is foobar // Using single quotes will print the variable name, not the value print 'foo is $foo'; // foo is $foo // If you are not using any other characters, you can just print variables print $foo; // foobar print <<<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! END; ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also <A HREF="function.echo.html" ><B CLASS="function" >echo()</B ></A >, <A HREF="function.printf.html" ><B CLASS="function" >printf()</B ></A >, and <A HREF="function.flush.html" ><B CLASS="function" >flush()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.parse-str.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.printf.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >parse_str</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.strings.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >printf</TD ></TR ></TABLE ></DIV ></BODY ></HTML >