Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 703

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>echo</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="crypt"
HREF="function.crypt.html"><LINK
REL="NEXT"
TITLE="explode"
HREF="function.explode.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.crypt.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.explode.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.echo"
></A
>echo</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN112965"
></A
><P
>    (PHP 3, PHP 4, PHP 5 )</P
>echo&nbsp;--&nbsp;Output one or more strings</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN112968"
></A
><H2
>Description</H2
>void <B
CLASS="methodname"
>echo</B
> ( string arg1 [, string argn...])<BR
></BR
><P
>&#13;     Outputs all parameters.
    </P
><P
>&#13;     <B
CLASS="function"
>echo()</B
> is not actually a function (it is a
     language construct) so you are not required to use parentheses
     with it. In fact, if you want to pass more than one parameter
     to echo, you must not enclose the parameters within parentheses.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN112983"
></A
><P
><B
>Exemplu 1. <B
CLASS="function"
>echo()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">echo </font><font color="#DD0000">"Hello World"</font><font color="#007700">;<br /><br />echo </font><font color="#DD0000">"This spans<br />multiple lines. The newlines will be <br />output as well"</font><font color="#007700">;<br /><br />echo </font><font color="#DD0000">"This spans\nmultiple lines. The newlines will be\noutput as well."</font><font color="#007700">;<br /><br />echo </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 an echo 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 />echo </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">=&gt; </font><font color="#DD0000">"foo"</font><font color="#007700">);<br /><br />echo </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">echo </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 echo variables<br /></font><font color="#007700">echo </font><font color="#0000BB">$foo</font><font color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// foobar<br /></font><font color="#007700">echo </font><font color="#0000BB">$foo</font><font color="#007700">,</font><font color="#0000BB">$bar</font><font color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// foobarbarbaz<br /><br />// Some people prefer passing multiple parameters to echo over concatenation.<br /></font><font color="#007700">echo </font><font color="#DD0000">'This '</font><font color="#007700">, </font><font color="#DD0000">'string '</font><font color="#007700">, </font><font color="#DD0000">'was '</font><font color="#007700">, </font><font color="#DD0000">'made '</font><font color="#007700">, </font><font color="#DD0000">'with multiple parameters.'</font><font color="#007700">, </font><font color="#0000BB">chr</font><font color="#007700">(</font><font color="#0000BB">10</font><font color="#007700">);<br />echo </font><font color="#DD0000">'This ' </font><font color="#007700">. </font><font color="#DD0000">'string ' </font><font color="#007700">. </font><font color="#DD0000">'was ' </font><font color="#007700">. </font><font color="#DD0000">'made ' </font><font color="#007700">. </font><font color="#DD0000">'with concatenation.' </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br />echo &lt;&lt;&lt;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 /><br /></font><font color="#FF8000">// Because echo is not a function, following code is invalid. <br /></font><font color="#007700">(</font><font color="#0000BB">$some_var</font><font color="#007700">) ? echo </font><font color="#DD0000">'true' </font><font color="#007700">: echo </font><font color="#DD0000">'false'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// However, the following examples will work:<br /></font><font color="#007700">(</font><font color="#0000BB">$some_var</font><font color="#007700">) ? print(</font><font color="#DD0000">'true'</font><font color="#007700">): print(</font><font color="#DD0000">'false'</font><font color="#007700">); </font><font color="#FF8000">// print is a function<br /></font><font color="#007700">echo </font><font color="#0000BB">$some_var </font><font color="#007700">? </font><font color="#DD0000">'true'</font><font color="#007700">: </font><font color="#DD0000">'false'</font><font color="#007700">; </font><font color="#FF8000">// changing the statement around<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <B
CLASS="function"
>echo()</B
> also has a shortcut syntax, where you can
     immediately follow the opening tag with an equals sign. This short syntax
     only works with the <A
HREF="ini.sect.language-options.html#ini.short-open-tag"
>short_open_tag</A
> configuration setting
     enabled.
     <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN112990"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
I have <font color="#0000BB">&lt;?=$foo?&gt;</font> foo.</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
    </P
><P
>&#13;     For a short discussion about the differences between 
     <A
HREF="function.print.html"
><B
CLASS="function"
>print()</B
></A
> and <B
CLASS="function"
>echo()</B
>, 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&#227;: </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
>&#13;     See also
     <A
HREF="function.print.html"
><B
CLASS="function"
>print()</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.crypt.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.explode.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>crypt</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"
>explode</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>