Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 2057

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>ini_get</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="PHP Options&Information"
HREF="ref.info.html"><LINK
REL="PREVIOUS"
TITLE="ini_get_all"
HREF="function.ini-get-all.html"><LINK
REL="NEXT"
TITLE="ini_restore"
HREF="function.ini-restore.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.ini-get-all.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ini-restore.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ini-get"
></A
>ini_get</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN181543"
></A
><P
>    (PHP 4, PHP 5)</P
>ini_get&nbsp;--&nbsp;Gets the value of a configuration option</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181546"
></A
><H2
>说明</H2
>string <B
CLASS="methodname"
>ini_get</B
> ( string varname )<BR
></BR
><P
>&#13;   Returns the value of the configuration option on success.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181555"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>varname</CODE
></DT
><DD
><P
>&#13;       The configuration option name.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181564"
></A
><H2
>返回值</H2
><P
>&#13;   Returns the value of the configuration option as a string on success, or
   an empty string on failure.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181567"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN181570"
></A
><P
><B
>例 1. A few <B
CLASS="function"
>ini_get()</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="#FF8000">/*<br />Our php.ini contains the following settings:<br /><br />display_errors = On<br />register_globals = Off<br />post_max_size = 8M<br />*/<br /><br /></font><font color="#007700">echo </font><font color="#DD0000">'display_errors = ' </font><font color="#007700">. </font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'display_errors'</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">'register_globals = ' </font><font color="#007700">. </font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'register_globals'</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">'post_max_size = ' </font><font color="#007700">. </font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'post_max_size'</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">'post_max_size+1 = ' </font><font color="#007700">. (</font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'post_max_size'</font><font color="#007700">)+</font><font color="#0000BB">1</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">'post_max_size in bytes = ' </font><font color="#007700">. </font><font color="#0000BB">return_bytes</font><font color="#007700">(</font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'post_max_size'</font><font color="#007700">));<br /><br />function </font><font color="#0000BB">return_bytes</font><font color="#007700">(</font><font color="#0000BB">$val</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">trim</font><font color="#007700">(</font><font color="#0000BB">$val</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$last </font><font color="#007700">= </font><font color="#0000BB">strtolower</font><font color="#007700">(</font><font color="#0000BB">$val</font><font color="#007700">{</font><font color="#0000BB">strlen</font><font color="#007700">(</font><font color="#0000BB">$val</font><font color="#007700">)-</font><font color="#0000BB">1</font><font color="#007700">});<br />&nbsp;&nbsp;&nbsp;&nbsp;switch(</font><font color="#0000BB">$last</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// The 'G' modifier is available since PHP 5.1.0<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">case </font><font color="#DD0000">'g'</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$val </font><font color="#007700">*= </font><font color="#0000BB">1024</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#DD0000">'m'</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$val </font><font color="#007700">*= </font><font color="#0000BB">1024</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#DD0000">'k'</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$val </font><font color="#007700">*= </font><font color="#0000BB">1024</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">$val</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例的输出类似于:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>display_errors = 1
register_globals = 0
post_max_size = 8M
post_max_size+1 = 9
post_max_size in bytes = 8388608</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181576"
></A
><H2
>注释</H2
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>When querying boolean values: </B
>
    A boolean ini value of <TT
CLASS="literal"
>off</TT
> will be returned as an
    empty string or "0" while a boolean ini value of <TT
CLASS="literal"
>on</TT
> will
    be returned as "1".
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>When querying memory size values: </B
>
    Many ini memory size values, such as
    <A
HREF="ini.core.html#ini.upload-max-filesize"
>upload_max_filesize</A
>, are
    stored in the <TT
CLASS="filename"
>php.ini</TT
> file in shorthand notation.
    <B
CLASS="function"
>ini_get()</B
> will return the exact string stored in the
    <TT
CLASS="filename"
>php.ini</TT
> file and <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>NOT</I
></SPAN
> its <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>
    equivalent.  Attempting normal arithmetic functions on these values
    will not have otherwise expected results.  The example below shows one
    way to convert shorthand notation into bytes, much like how the PHP
    source does it.
   </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN181592"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.get-cfg-var.html"
><B
CLASS="function"
>get_cfg_var()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.ini-get-all.html"
><B
CLASS="function"
>ini_get_all()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.ini-restore.html"
><B
CLASS="function"
>ini_restore()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.ini-set.html"
><B
CLASS="function"
>ini_set()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </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.ini-get-all.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ini-restore.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>ini_get_all</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.info.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>ini_restore</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>