Sophie

Sophie

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>eval</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="Miscellaneous Functions"
HREF="ref.misc.html"><LINK
REL="PREVIOUS"
TITLE="die"
HREF="function.die.html"><LINK
REL="NEXT"
TITLE="exit"
HREF="function.exit.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.die.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.exit.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.eval"
></A
>eval</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN63641"
></A
><P
>    (PHP 3, PHP 4, PHP 5 )</P
>eval&nbsp;--&nbsp;Evaluate a string as PHP code</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN63644"
></A
><H2
>Description</H2
>mixed <B
CLASS="methodname"
>eval</B
> ( string code_str)<BR
></BR
><P
>&#13;     <B
CLASS="function"
>eval()</B
> evaluates the string given in
     <VAR
CLASS="parameter"
>code_str</VAR
> as PHP code. Among other things,
     this can be useful for storing code in a database text field for
     later execution.
    </P
><P
>&#13;     There are some factors to keep in mind when using
     <B
CLASS="function"
>eval()</B
>. Remember that the string passed must
     be valid PHP code, including things like terminating statements
     with a semicolon so the parser doesn't die on the line after the
     <B
CLASS="function"
>eval()</B
>, and properly escaping things in
     <VAR
CLASS="parameter"
>code_str</VAR
>.
    </P
><P
>&#13;     Also remember that variables given values under
     <B
CLASS="function"
>eval()</B
> will retain these values in the main
     script afterwards.
    </P
><P
>&#13;     A <VAR
CLASS="literal"
>return</VAR
> statement will terminate the evaluation of 
     the string immediately. In PHP 4, <B
CLASS="function"
>eval()</B
> returns
     <TT
CLASS="constant"
><B
>NULL</B
></TT
> unless <VAR
CLASS="literal"
>return</VAR
> is called in the evaluated
     code, in which case the value passed to <VAR
CLASS="literal"
>return</VAR
> is
     returned. In PHP 3, <B
CLASS="function"
>eval()</B
> does not return a value.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN63669"
></A
><P
><B
>Exemplu 1. 
       <B
CLASS="function"
>eval()</B
> example - simple text merge
      </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$string </font><font color="#007700">= </font><font color="#DD0000">'cup'</font><font color="#007700">;<br /></font><font color="#0000BB">$name </font><font color="#007700">= </font><font color="#DD0000">'coffee'</font><font color="#007700">;<br /></font><font color="#0000BB">$str </font><font color="#007700">= </font><font color="#DD0000">'This is a $string with my $name in it.'</font><font color="#007700">;<br />echo </font><font color="#0000BB">$str</font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />eval(</font><font color="#DD0000">"</font><font color="#007700">\$</font><font color="#DD0000">str = </font><font color="#007700">\"</font><font color="#DD0000">$str</font><font color="#007700">\"</font><font color="#DD0000">;"</font><font color="#007700">);<br />echo </font><font color="#0000BB">$str</font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;       The above example will show:
      </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>This is a $string with my $name in it.
This is a cup with my coffee in it.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="tip"
><BLOCKQUOTE
CLASS="tip"
><P
><B
>Indica&#254;ie: </B
>Cum toate funcþiile afiºeazã
rezultatele direct cãtre browser, se pot folosi
<A
HREF="ref.outcontrol.html"
>funcþiile de control a ieºirii</A
>
pentru a captura rezultatul acestei funcþii ºi a-l salva, de exemplu,
într-un <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>.</P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also <A
HREF="function.call-user-func.html"
><B
CLASS="function"
>call_user_func()</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.die.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.exit.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>die</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.misc.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>exit</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>