<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >print</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" 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-2"></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" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.parse-str.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.printf.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.print" ></A >print</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN114453" ></A ><P > (PHP 3, PHP 4, PHP 5 )</P >print -- Output a string</DIV ><DIV CLASS="refsect1" ><A NAME="AEN114456" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >print</B > ( string arg)<BR ></BR ><P > Outputs <VAR CLASS="parameter" >arg</VAR >. Returns <VAR CLASS="literal" >1</VAR >, always. </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 its argument list. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN114470" ></A ><P ><B >Exemplu 1. <B CLASS="function" >print()</B > examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">print(</font><font color="#DD0000">"Hello World"</font><font color="#007700">);<br /><br />print </font><font color="#DD0000">"print() also works without parentheses."</font><font color="#007700">;<br /><br />print </font><font color="#DD0000">"This spans<br />multiple lines. The newlines will be <br />output as well"</font><font color="#007700">;<br /><br />print </font><font color="#DD0000">"This spans\nmultiple lines. The newlines will be\noutput as well."</font><font color="#007700">;<br /><br />print </font><font color="#DD0000">"escaping characters is done \"Like this\"."</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// You can use variables inside of a print statement<br /></font><font color="#0000BB">$foo </font><font color="#007700">= </font><font color="#DD0000">"foobar"</font><font color="#007700">;<br /></font><font color="#0000BB">$bar </font><font color="#007700">= </font><font color="#DD0000">"barbaz"</font><font color="#007700">;<br /><br />print </font><font color="#DD0000">"foo is $foo"</font><font color="#007700">; </font><font color="#FF8000">// foo is foobar<br /><br />// You can also use arrays<br /></font><font color="#0000BB">$bar </font><font color="#007700">= array(</font><font color="#DD0000">"value" </font><font color="#007700">=> </font><font color="#DD0000">"foo"</font><font color="#007700">);<br /><br />print </font><font color="#DD0000">"this is </font><font color="#007700">{</font><font color="#DD0000">$bar</font><font color="#007700">[</font><font color="#DD0000">'value'</font><font color="#007700">]}</font><font color="#DD0000"> !"</font><font color="#007700">; </font><font color="#FF8000">// this is foo !<br /><br />// Using single quotes will print the variable name, not the value<br /></font><font color="#007700">print </font><font color="#DD0000">'foo is $foo'</font><font color="#007700">; </font><font color="#FF8000">// foo is $foo<br /><br />// If you are not using any other characters, you can just print variables<br /></font><font color="#007700">print </font><font color="#0000BB">$foo</font><font color="#007700">; </font><font color="#FF8000">// foobar<br /><br /></font><font color="#007700">print <<<END<br /></font><font color="#0000BB">This uses the "here document" syntax to output<br />multiple lines with $variable interpolation. Note<br />that the here document terminator must appear on a<br />line with just a semicolon no extra whitespace!<br /></font><font color="#007700">END;<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > For a short discussion about the differences between <B CLASS="function" >print()</B > and <A HREF="function.echo.html" ><B CLASS="function" >echo()</B ></A >, see this FAQTs Knowledge Base Article: <A HREF="http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40" TARGET="_top" >http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 </A > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B >Because this is a language construct and not a function, it cannot be called using <A HREF="functions.variable-functions.html" >variable functions</A ></P ></BLOCKQUOTE ></DIV ><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" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.printf.html" ACCESSKEY="N" >Înainte</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" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >printf</TD ></TR ></TABLE ></DIV ></BODY ></HTML >