⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faq.using.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 3 页
字号:
</b><br />The <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a>directive defaults to <i>on</i>. It essentially runs<a href="function.addslashes.html" class="function">addslashes()</a> on all GET, POST, and COOKIE data.<a href="function.stripslashes.html" class="function">stripslashes()</a> may be used to remove them.<br /></p></blockquote>         </dd>   </dl>      <dl>    <dt><strong>     <p class="para">      How does the PHP directive register_globals affect me?     </p>    </strong></dt>    <dd><a name="faq.register-globals"></a>     <p class="para">      First, an explanation about what this ini setting does. Let&#039;s say the      following URL is used:      <i>http://example.com/foo.php?animal=cat</i>      and in <var class="filename">foo.php</var> we might have the following      PHP code:     </p>     <p class="para">      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Using&nbsp;$_GET&nbsp;here&nbsp;is&nbsp;preferred<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'animal'</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">//&nbsp;For&nbsp;$animal&nbsp;to&nbsp;exist,&nbsp;register_globals&nbsp;must&nbsp;be&nbsp;on<br />//&nbsp;DO&nbsp;NOT&nbsp;DO&nbsp;THIS<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$animal</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;applies&nbsp;to&nbsp;all&nbsp;variables,&nbsp;so&nbsp;$_SERVER&nbsp;too<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">'PHP_SELF'</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">//&nbsp;Again,&nbsp;for&nbsp;$PHP_SELF&nbsp;to&nbsp;exist,&nbsp;register_globals&nbsp;must&nbsp;be&nbsp;on<br />//&nbsp;DO&nbsp;NOT&nbsp;DO&nbsp;THIS<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$PHP_SELF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </p>    <p class="para">     The code above demonstrates how register_globals creates a lot of     variables. For years this type of coding has been frowned upon, and for     years it&#039;s been disabled by default. Note that PHP 6 removes this     deprecated feature. So although most web hosts disable register_globals,     there are still outdated articles, tutorials, and books that require it     to be on. Plan accordingly.    </p>    <p class="para">     See also the following resources for additional information:     <ul class="simplelist">      <li class="member">The <a href="ini.core.html#ini.register-globals" class="link">register_globals</a> directive</li>      <li class="member">The <a href="security.globals.html" class="link">security chapter about register globals</a></li>      <li class="member"><a href="language.variables.external.html" class="link">Handling external variables</a></li>      <li class="member">Use <a href="language.variables.superglobals.html" class="link">superglobals</a> instead</li>     </ul>    </p>    <blockquote><p><b class="note">Note</b>:            In the example above, we used an <acronym title="Uniform Resource Locator">URL</acronym> that contained      a QUERY_STRING. Passing information like this is done through a GET HTTP      Request, so this is why the superglobal <var class="varname"><a href="reserved.variables.get.html" class="classname">$_GET</a></var> was used.     <br />    </p></blockquote>   </dd>  </dl>   <dl>    <dt><strong>     <p class="para">      When I do the following, the output is printed in       the wrong order:      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">myfunc</span><span style="color: #007700">(</span><span style="color: #0000BB">$argument</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$argument&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">$variable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"myfunc($variable)&nbsp;=&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">myfunc</span><span style="color: #007700">(</span><span style="color: #0000BB">$variable</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>     what&#039;s going on?     </p>    </strong></dt>    <dd><a name="faq.using.wrong-order"></a>     <p class="para">      To be able to use the results of your function in an expression (such      as concatenating it with other strings in the example above), you need      to <b>return()</b> the value, not <a href="function.echo.html" class="function">echo()</a>       it.     </p>    </dd>   </dl>   <dl>    <dt><strong>     <p class="para">      Hey, what happened to my newlines?      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">&lt;pre&gt;<br /><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;should&nbsp;be&nbsp;the&nbsp;first&nbsp;line."</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;<br />&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;should&nbsp;show&nbsp;up&nbsp;after&nbsp;the&nbsp;new&nbsp;line&nbsp;above."</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>&lt;/pre&gt;</span></code></div>      </div>     </p>    </strong></dt>    <dd><a name="faq.using.newlines"></a>     <p class="para">      In PHP, the ending for a block of code is either &quot;?&gt;&quot; or      &quot;?&gt;\n&quot; (where \n means a newline). So in the example above,      the echoed sentences will be on one line, because PHP omits      the newlines after the block ending. This means that you need to      insert an extra newline after each block of PHP code to make      it print out one newline.     </p>     <p class="para">      Why does PHP do this? Because when formatting normal HTML, this      usually makes your life easier because you don&#039;t want that newline,      but you&#039;d have to create extremely long lines or otherwise make the      raw page source unreadable to achieve that effect.     </p>    </dd>   </dl>   <dl>    <dt><strong>     <p class="para">      I get the message &#039;Warning: Cannot send session cookie - headers already      sent...&#039; or &#039;Cannot add header information - headers already sent...&#039;.     </p>    </strong></dt>    <dd><a name="faq.using.headers-sent"></a>     <p class="para">      The functions <a href="function.header.html" class="function">header()</a>, <a href="function.setcookie.html" class="function">setcookie()</a>,      and the <a href="ref.session.html" class="link">session       functions</a> need to add headers to the output stream but headers       can only be sent before all other content.  There can be no output      before using these functions, output such as HTML.  The function <b>      headers_sent()</b> will check if your script has already sent       headers and see also the <a href="ref.outcontrol.html" class="link">Output Control      functions</a>.     </p>    </dd>   </dl>   <dl>    <dt><strong>     <p class="para">      I need to access information in the request header directly.       How can I do this?     </p>    </strong></dt>    <dd><a name="faq.using.header"></a>     <p class="para">      The <a href="function.getallheaders.html" class="function">getallheaders()</a> function will do this if       you are running PHP as an Apache module. So, the following bit      of code will show you all the request headers:      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$headers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getallheaders</span><span style="color: #007700">();<br />foreach&nbsp;(</span><span style="color: #0000BB">$headers&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$content</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"headers[$name]&nbsp;=&nbsp;$content&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>      </div>     </p>     <p class="para">      See also       <a href="function.apache-lookup-uri.html" class="function">apache_lookup_uri()</a>,      <a href="function.apache-response-headers.html" class="function">apache_response_headers()</a>, and      <a href="function.fsockopen.html" class="function">fsockopen()</a>     </p>    </dd>   </dl>   <dl>    <dt><strong>     <p class="para">      When I try to use authentication with IIS I get &#039;No Input file specified&#039;.     </p>    </strong></dt>    <dd><a name="faq.using.authentication"></a>     <p class="para">      The security model of IIS is at fault here. This is a problem      common to all CGI programs running under IIS. A workaround is      to create a plain HTML file (not parsed by PHP) as the entry page      into an authenticated directory. Then use a META tag to redirect      to the PHP page, or have a link to the PHP page. PHP will      then recognize the authentication correctly. With the ISAPI      module, this is not a problem. This should not effect other      NT web servers. For more information, see:       <a href="http://support.microsoft.com/kb/q160422/" class="link external">&raquo; http://support.microsoft.com/kb/q160422/</a> and the manual      section on <a href="features.http-auth.html" class="link">HTTP Authentication      </a>.     </p>    </dd>   </dl>   <dl>    <dt><strong>     <p class="para">      Windows: I can&#039;t access files shared on another computer using IIS     </p>    </strong></dt>    <dd><a name="faq.using.iis.sharing"></a>     <p class="para">      You have to change the <i>Go to Internet Information      Services</i>. Locate your PHP file and go to its properties.      Go to the <i>File Security</i> tab, <i>Edit -&lt;       Anonymous access and authentication control</i>.     </p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -