uTools-Manuals/docs/php/get_magic_quotes_gpc.html
2019-04-28 19:00:34 +08:00

116 lines
7.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>获取当前 magic_quotes_gpc 的配置选项设置</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.get-magic-quotes-gpc" class="refentry">
<div class="refnamediv">
<h1 class="refname">get_magic_quotes_gpc</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">get_magic_quotes_gpc</span> &mdash; <span class="dc-title">获取当前 magic_quotes_gpc 的配置选项设置</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.get-magic-quotes-gpc-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>get_magic_quotes_gpc</strong></span>
( <span class="methodparam">void</span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
返回当前 <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a> 配置选项的设置
</p>
<p class="para">
记住,尝试在运行时设置 <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">
magic_quotes_gpc</a> 将不会生效。
</p>
<p class="para">
更多关于 magic_quotes 的信息参见<a href="security.magicquotes.html" class="link">安全</a>一章。
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.get-magic-quotes-gpc-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
如果 magic_quotes_gpc 为关闭时返回 0否则返回 1。在 PHP 5.4.O 起将始终返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 changelog" id="refsect1-function.get-magic-quotes-gpc-changelog">
<h3 class="title">更新日志</h3>
<p class="para">
<table class="doctable informaltable">
<thead>
<tr>
<th>版本</th>
<th>说明</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>5.4.0</td>
<td>
始终返回 <strong><code>FALSE</code></strong>,因为这个魔术引号功能已经从 PHP 中移除了。
</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.get-magic-quotes-gpc-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-501">
<p><strong>Example #1 <span class="function"><strong>get_magic_quotes_gpc()</strong></span> 例子</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;如果启用了魔术引号<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;O\'reilly<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">]);&nbsp;</span><span style="color: #FF8000">//&nbsp;O\\\'reilly<br /><br />//&nbsp;适用各个&nbsp;PHP&nbsp;版本的用法<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">get_magic_quotes_gpc</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$lastname&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stripslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">]);<br />}<br />else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$lastname&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">];<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;如果使用&nbsp;MySQL<br /></span><span style="color: #0000BB">$lastname&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_real_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$lastname</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$lastname</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;O\'reilly<br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;lastnames&nbsp;(lastname)&nbsp;VALUES&nbsp;('</span><span style="color: #0000BB">$lastname</span><span style="color: #DD0000">')"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.get-magic-quotes-gpc-notes">
<h3 class="title">注释</h3>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
如果指令 <a href="sybase.configuration.html#ini.magic-quotes-sybase" class="link">
magic_quotes_sybase</a> 为 ON它会完全覆盖 <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a>
所以即使 <span class="function"><strong>get_magic_quotes_gpc()</strong></span> 返回 <strong><code>TRUE</code></strong>,双引号、反斜杠或 NUL 都不会被转义。
只有单引号会被转义。
这种情况下它们看上去像:<em class="emphasis">&#039;&#039;</em>
</p>
</p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.get-magic-quotes-gpc-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="addslashes.html" class="function" rel="rdfs-seeAlso">addslashes()</a> - 使用反斜线引用字符串</span></li>
<li class="member"><span class="function"><a href="stripslashes.html" class="function" rel="rdfs-seeAlso">stripslashes()</a> - 反引用一个引用字符串</span></li>
<li class="member"><span class="function"><a href="get_magic_quotes_runtime.html" class="function" rel="rdfs-seeAlso">get_magic_quotes_runtime()</a> - 获取当前 magic_quotes_runtime 配置选项的激活状态</span></li>
<li class="member"><span class="function"><a href="ini_get.html" class="function" rel="rdfs-seeAlso">ini_get()</a> - 获取一个配置选项的值</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>