Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 2035

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>parse_ini_file</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Funciones del sistema de ficheros"
HREF="ref.filesystem.html"><LINK
REL="PREVIOUS"
TITLE="move_uploaded_file"
HREF="function.move-uploaded-file.html"><LINK
REL="NEXT"
TITLE="pathinfo"
HREF="function.pathinfo.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"
>Manual de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.move-uploaded-file.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.pathinfo.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.parse-ini-file"
></A
>parse_ini_file</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN20209"
></A
><P
>    (PHP 4 )</P
>parse_ini_file&nbsp;--&nbsp;Parse a configuration file</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN20212"
></A
><H2
>Description</H2
>array <B
CLASS="methodname"
>parse_ini_file</B
> ( string filename [, bool process_sections])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>parse_ini_file()</B
> loads in the
     ini file specified in <TT
CLASS="parameter"
><I
>filename</I
></TT
>,
     and returns the settings in it in an associative array.
     By setting the last <TT
CLASS="parameter"
><I
>process_sections</I
></TT
>
     parameter to <TT
CLASS="constant"
><B
>TRUE</B
></TT
>, you get a multidimensional array, with
     the section names and settings included. The default
     for <TT
CLASS="parameter"
><I
>process_sections</I
></TT
> is <TT
CLASS="constant"
><B
>FALSE</B
></TT
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      This function has nothing to do with the
      <TT
CLASS="filename"
>php.ini</TT
> file. It is already processed,
      the time you run your script. This function can be used to
      read in your own application's configuration files.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      If a value in the ini file contains any non-alphanumeric
      characters it needs to be enclosed in double-quotes (").
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Since PHP 4.2.1 this function is also affected by <A
HREF="configuration.html#ini.safe-mode"
>safe_mode</A
> and <A
HREF="configuration.html#ini.open-basedir"
>open_basedir</A
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     The structure of the ini file is similar to that of
     the <TT
CLASS="filename"
>php.ini</TT
>'s.
    </P
><P
>&#13;     <A
HREF="language.constants.html"
>Constants</A
> may also be parsed
     in the ini file so if you define a constant as an ini value before
     running <B
CLASS="function"
>parse_ini_file()</B
>, it will be integrated into
     the results.  Only ini values are evaluated.  For example:  
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN20245"
></A
><P
><B
>Ejemplo 1. Contents of <TT
CLASS="filename"
>sample.ini</TT
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>; This is a sample configuration file
; Comments start with ';', as in php.ini

[first_section]
one = 1
five = 5
animal = BIRD

[second_section]
path = /usr/local/bin
URL = "http://www.example.com/~username"</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN20250"
></A
><P
><B
>Ejemplo 2. <B
CLASS="function"
>parse_ini_file()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>&#60;?php

define ('BIRD', 'Dodo bird');

// Parse without sections
$ini_array = parse_ini_file("sample.ini");
print_r($ini_array);

// Parse with sections
$ini_array = parse_ini_file("sample.ini", TRUE);
print_r($ini_array);

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Would produce:
     <DIV
CLASS="informalexample"
><A
NAME="AEN20255"
></A
><P
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>Array
(
    [one] =&#62; 1
    [five] =&#62; 5
    [animal] =&#62; Dodo bird
    [path] =&#62; /usr/local/bin
    [URL] =&#62; http://www.example.com/~username
)
Array
(
    [first_section] =&#62; Array
        (
            [one] =&#62; 1
            [five] =&#62; 5
            [animal] = Dodo bird
        )

    [second_section] =&#62; Array
        (
            [path] =&#62; /usr/local/bin
            [URL] =&#62; http://www.example.com/~username
        )

)</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
>
    </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.move-uploaded-file.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.pathinfo.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>move_uploaded_file</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.filesystem.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>pathinfo</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>