Sophie

Sophie

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

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
>杂类问题</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="FAQ:常见问题"
HREF="faq.html"><LINK
REL="PREVIOUS"
TITLE="从 PHP 4 移植到 PHP 5 "
HREF="faq.migration5.html"><LINK
REL="NEXT"
TITLE="Appendices"
HREF="appendices.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="chapter"
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="faq.migration5.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="appendices.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="faq.misc"
>章 62. 杂类问题</A
></H1
><P
>&#13;    有些问题没法归到其它类中,可以在这里找到。
   </P
><DIV
CLASS="qandaset"
><DL
><DT
>1. <A
HREF="faq.misc.html#faq.misc.bz2"
>&#13;      在 Windows 中怎样处理 bz2 压缩的文档?
     </A
></DT
><DT
>2. <A
HREF="faq.misc.html#faq.misc.arguments.references"
>&#13;      在函数定义中,参数旁边的 &#38; 是什么意思?例如
      <A
HREF="function.asort.html"
><B
CLASS="function"
>asort()</B
></A
>。
     </A
></DT
><DT
>3. <A
HREF="faq.misc.html#faq.misc.registerglobals"
>&#13;      怎么处理 <TT
CLASS="literal"
>register_globals</TT
>?
     </A
></DT
></DL
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.misc.bz2"
></A
><B
>1. </B
>
      在 Windows 中怎样处理 bz2 压缩的文档?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      如果没有能处理 bz2 文件的压缩工具,从 Redhat
      <A
HREF="http://www.bzip.org/"
TARGET="_top"
>下载</A
>一个命令行工具(进一步信息见下面)。
     </P
><P
>&#13;      如果不喜欢用命令行工具,可以试试免费工具例如 <A
HREF="http://www.stuffit.com/"
TARGET="_top"
>Stuffit Expander</A
>,<A
HREF="http://www.ultimatezip.com/"
TARGET="_top"
>UltimateZip</A
>,<A
HREF="http://www.7-zip.org/"
TARGET="_top"
>7-Zip</A
> 或者 <A
HREF="http://www.quickzip.org/"
TARGET="_top"
>Quick Zip</A
>。如果有像 <A
HREF="http://www.rarlab.com/"
TARGET="_top"
>WinRAR</A
> 或者 <A
HREF="http://www.powerarchiver.com/"
TARGET="_top"
>Power Archiver</A
>
      之类的工具,可以很容易用它解压缩 bz2 文件。如果用
      Total Commander(前身为 Windows Commander),可以从
      <A
HREF="http://www.ghisler.com/"
TARGET="_top"
>Total Commander</A
> 网站免费得到一个 bz2 插件。
     </P
><P
>&#13;      来自 Redhat 的 bzip2 命令行工具:
     </P
><P
>&#13;      Win2K Sp2 用户下载最新版本 1.0.2,所有其它 Windows 用户应该用版本 1.00。下载后重命名可执行文件为
      bzip2.exe。为方便起见将其放到一个在你路径中的目录,例如 C:\Windows,C 表示你安装 Windows 的盘符。
     </P
><P
>&#13;      注意:lang 指的是你的语种,x 是想要的格式,例如:pdf。要解压缩
      php_manual_lang.x.bz2,按照下面的简单说明进行:
      <P
></P
><UL
><LI
><P
>打开一个命令行窗口</P
></LI
><LI
><P
>&#13;         进入存放已下载的 php_manual_lang.x.bz2 的目录
        </P
></LI
><LI
><P
>&#13;         调用 bzip2 -d php_manual_lang.x.bz2,将 php_manual_lang.x 释放到同一个目录
        </P
></LI
></UL
>
     </P
><P
>&#13;      在下载了包含很多 html 文件的 php_manual_lang.tar.bz2 的情况下,过程是一样的。唯一区别是得到了一个
      php_manual_lang.tar 文件。tar 格式可以被大多数 Windows 下流行的压缩工具所处理,例如 <A
HREF="http://www.winzip.com/"
TARGET="_top"
>WinZip</A
>。
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.misc.arguments.references"
></A
><B
>2. </B
>
      在函数定义中,参数旁边的 &#38; 是什么意思?例如
      <A
HREF="function.asort.html"
><B
CLASS="function"
>asort()</B
></A
>。
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      这表示该参数是<A
HREF="language.references.pass.html"
>引用传递</A
>,该函数会修改其值。只可以用此方法传递变量,其实都不需要在函数调用中用
      &#38; 传递(此方式都已<A
HREF="ini.core.html#ini.allow-call-time-pass-reference"
>过时了</A
>)。
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.misc.registerglobals"
></A
><B
>3. </B
>
      怎么处理 <TT
CLASS="literal"
>register_globals</TT
>?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      有关 <TT
CLASS="literal"
>register_globals</TT
>
      实现方面的安全性,请阅读<A
HREF="security.globals.html"
>使用 register_globals</A
>
      一章。
     </P
><P
>&#13;      推荐使用<A
HREF="language.variables.predefined.html#language.variables.superglobals"
>超全局变量</A
>而不要依赖
      <TT
CLASS="literal"
>register_globals</TT
>。
     </P
><P
>&#13;      如果需要在一台关闭了 <TT
CLASS="literal"
>register_globals</TT
>
      的共享主机上运行一些旧式程序而该程序需要此选项打开时,或者在一些打开了此选项的主机上但想消除安全隐患,那么就需要用
      PHP 来模拟出相反的设定。最好先问清楚是否能否在哪里更改
      PHP 配置的选项,如果不行,那可以用如下的兼容手段。
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN289216"
></A
><P
><B
>例 62-1. 模拟注册全局变量</B
></P
><P
>&#13;        本例模拟 register_globals On。如果改变了配置文件中的 <A
HREF="ini.core.html#ini.variables-order"
>variables_order</A
> 选项,则考虑对
        <CODE
CLASS="varname"
>$superglobals</CODE
> 作出相应的改动。
       </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// Emulate register_globals on<br /></font><font color="#007700">if (!</font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'register_globals'</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$superglobals </font><font color="#007700">= array(</font><font color="#0000BB">$_SERVER</font><font color="#007700">, </font><font color="#0000BB">$_ENV</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$_FILES</font><font color="#007700">, </font><font color="#0000BB">$_COOKIE</font><font color="#007700">, </font><font color="#0000BB">$_POST</font><font color="#007700">, </font><font color="#0000BB">$_GET</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if (isset(</font><font color="#0000BB">$_SESSION</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">array_unshift</font><font color="#007700">(</font><font color="#0000BB">$superglobals</font><font color="#007700">, </font><font color="#0000BB">$_SESSION</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach (</font><font color="#0000BB">$superglobals </font><font color="#007700">as </font><font color="#0000BB">$superglobal</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">extract</font><font color="#007700">(</font><font color="#0000BB">$superglobal</font><font color="#007700">, </font><font color="#0000BB">EXTR_SKIP</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;        本例模拟 register_globals Off。要记住此代码应在脚本最开头的地方调用。如果使用了会话机制,则在
        <A
HREF="function.session-start.html"
><B
CLASS="function"
>session_start()</B
></A
> 之后调用。
       </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// Emulate register_globals off<br /></font><font color="#007700">function </font><font color="#0000BB">unregister_GLOBALS</font><font color="#007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if (!</font><font color="#0000BB">ini_get</font><font color="#007700">(</font><font color="#DD0000">'register_globals'</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Might want to change this perhaps to a nicer error<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">if (isset(</font><font color="#0000BB">$_REQUEST</font><font color="#007700">[</font><font color="#DD0000">'GLOBALS'</font><font color="#007700">]) || isset(</font><font color="#0000BB">$_FILES</font><font color="#007700">[</font><font color="#DD0000">'GLOBALS'</font><font color="#007700">])) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</font><font color="#DD0000">'GLOBALS overwrite attempt detected'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Variables that shouldn't be unset<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$noUnset </font><font color="#007700">= array(</font><font color="#DD0000">'GLOBALS'</font><font color="#007700">,&nbsp;&nbsp;</font><font color="#DD0000">'_GET'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'_POST'</font><font color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'_COOKIE'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'_REQUEST'</font><font color="#007700">, </font><font color="#DD0000">'_SERVER'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'_ENV'</font><font color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'_FILES'</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$input </font><font color="#007700">= </font><font color="#0000BB">array_merge</font><font color="#007700">(</font><font color="#0000BB">$_GET</font><font color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$_POST</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$_COOKIE</font><font color="#007700">, </font><font color="#0000BB">$_SERVER</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$_ENV</font><font color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$_FILES</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isset(</font><font color="#0000BB">$_SESSION</font><font color="#007700">) &amp;&amp; </font><font color="#0000BB">is_array</font><font color="#007700">(</font><font color="#0000BB">$_SESSION</font><font color="#007700">) ? </font><font color="#0000BB">$_SESSION </font><font color="#007700">: array());<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;foreach (</font><font color="#0000BB">$input </font><font color="#007700">as </font><font color="#0000BB">$k </font><font color="#007700">=&gt; </font><font color="#0000BB">$v</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!</font><font color="#0000BB">in_array</font><font color="#007700">(</font><font color="#0000BB">$k</font><font color="#007700">, </font><font color="#0000BB">$noUnset</font><font color="#007700">) &amp;&amp; isset(</font><font color="#0000BB">$GLOBALS</font><font color="#007700">[</font><font color="#0000BB">$k</font><font color="#007700">])) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unset(</font><font color="#0000BB">$GLOBALS</font><font color="#007700">[</font><font color="#0000BB">$k</font><font color="#007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></font><font color="#0000BB">unregister_GLOBALS</font><font color="#007700">();<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
></DIV
></DIV
></DIV
></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="faq.migration5.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="appendices.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>从 PHP 4 移植到 PHP 5</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="faq.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Appendices</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>