Sophie

Sophie

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>How to read a function definition (prototype)</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="About the manual"
HREF="about.html"><LINK
REL="PREVIOUS"
TITLE="About user notes"
HREF="about.notes.html"><LINK
REL="NEXT"
TITLE="PHP versions documented in this manual"
HREF="about.phpversions.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-2"></HEAD
><BODY
CLASS="sect1"
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="about.notes.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Anexa Q. About the manual</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="about.phpversions.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="about.prototypes"
>How to read a function definition (prototype)</A
></H1
><P
>&#13;    Each function in the manual is documented for quick reference. Knowing how 
    to read and understand the text will make learning PHP 
    much easier.  Rather than relying on examples or cut/paste, you will want 
    to know how to read function definitions (prototypes).  Let's begin:
   </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Prerequisite: Basic understanding of <A
HREF="language.types.html"
>types</A
>: </B
>
     Although PHP is a loosely typed language, it's important to have 
     a basic understanding of <A
HREF="language.types.html"
>types</A
> as 
     they have important meaning.
    </P
></BLOCKQUOTE
></DIV
><P
>&#13;    Function definitions tell us what 
    type of value is <A
HREF="functions.returning-values.html"
>returned</A
>.
    Let's use the definition for <A
HREF="function.strlen.html"
><B
CLASS="function"
>strlen()</B
></A
> as our first example:
   </P
><P
>&#13;    <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>strlen

(PHP 3, PHP 4, PHP 5)
strlen -- Get string length

Description
int strlen ( string str )

Returns the length of string.</PRE
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    <DIV
CLASS="table"
><A
NAME="AEN142476"
></A
><P
><B
>Tabel Q-1. Explanation of a function definition</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Part</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>&#13;          strlen
         </TD
><TD
>&#13;          The function name.
         </TD
></TR
><TR
><TD
>&#13;          (PHP 3, PHP 4, PHP 5)
         </TD
><TD
>&#13;          strlen() has been around in all versions of PHP 3, PHP 4 and PHP 5
         </TD
></TR
><TR
><TD
>&#13;          int
         </TD
><TD
>&#13;          Type of value this function returns, which is an 
          <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
> (i.e. the length of a string is measured in
          numbers). 
         </TD
></TR
><TR
><TD
>&#13;          ( string str )
         </TD
><TD
>&#13;          The first (and in this case the only) parameter/argument for this 
          function is named <VAR
CLASS="parameter"
>str</VAR
>, and it's a 
          <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>.
         </TD
></TR
></TBODY
></TABLE
></DIV
>
    </P
><P
>&#13;     We could rewrite the above function definition in a generic way:
    </P
><P
>&#13;     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>returned type    function name    ( parameter type   parameter name )</PRE
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Many functions take on multiple parameters, such as <A
HREF="function.in-array.html"
><B
CLASS="function"
>in_array()</B
></A
>.
     Its prototype is as follows:
    </P
><P
>&#13;     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>bool in_array ( mixed needle, array haystack [, bool strict])</PRE
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     What does this mean?  in_array() returns a 
     <A
HREF="language.types.boolean.html"
>boolean</A
> value, <TT
CLASS="constant"
><B
>TRUE</B
></TT
> on 
     success (if the <VAR
CLASS="parameter"
>needle</VAR
> was found in the 
     <VAR
CLASS="parameter"
>haystack</VAR
>) or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on failure (if the 
     <VAR
CLASS="parameter"
>needle</VAR
> was not found in the 
     <VAR
CLASS="parameter"
>haystack</VAR
>).  The first parameter is named 
     <VAR
CLASS="parameter"
>needle</VAR
> and it can be of many different 
     <A
HREF="language.types.html"
>types</A
>, so we call it 
     "<SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>mixed</I
></SPAN
>".  This mixed <VAR
CLASS="parameter"
>needle</VAR
> 
     (what we're looking for) can be either a scalar value (string, integer, 
     or <A
HREF="language.types.float.html"
>float</A
>), or an
     <A
HREF="language.types.array.html"
>array</A
>.
     <VAR
CLASS="parameter"
>haystack</VAR
> (the array we're searching in) is the 
     second parameter.  The third <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>optional</I
></SPAN
> parameter is 
     named <VAR
CLASS="parameter"
>strict</VAR
>.  All optional parameters are seen 
     in <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>[</I
></SPAN
> brackets <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>]</I
></SPAN
>.  The manual 
     states that the <VAR
CLASS="parameter"
>strict</VAR
> parameter defaults to 
     boolean <TT
CLASS="constant"
><B
>FALSE</B
></TT
>.  See the manual page on each function for details on 
     how they work.
    </P
><P
>&#13;     There are also functions with more complex PHP version information. Take
     <A
HREF="function.html-entity-decode.html"
><B
CLASS="function"
>html_entity_decode()</B
></A
> as an example:
    </P
><P
>&#13;     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>(PHP 4 &#62;= 4.3.0, PHP 5)</PRE
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     This means that this function was not available in PHP 3, and is only
     available in a released version since PHP 4.3.0. 
    </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="about.notes.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="about.phpversions.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>About user notes</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="about.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>PHP versions documented in this manual</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>