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

📄 function.addslashes.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Quote string with slashes</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.addcslashes.html">addcslashes</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.bin2hex.html">bin2hex</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.addslashes" class="refentry"> <div class="refnamediv">  <h1 class="refname">addslashes</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">addslashes</span> &mdash; <span class="dc-title">Quote string with slashes</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">string</span> <span class="methodname"><b><b>addslashes</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span>   )</div>  <p class="para rdfs-comment">   Returns a string with backslashes before characters that need   to be quoted in database queries etc.  These characters are   single quote (<i>&#039;</i>), double quote   (<i>&quot;</i>), backslash (<i>\</i>)   and NUL (the <b><tt>NULL</tt></b> byte).  </p>  <p class="para">   An example use of <b>addslashes()</b> is when you&#039;re   entering data into a database.  For example, to insert the name   <i>O&#039;reilly</i> into a database, you will need to escape   it.  Most databases do this with a <i>\</i> which would   mean <i>O\&#039;reilly</i>.  This would only be to get the data   into the database, the extra <i>\</i> will not be inserted.   Having the PHP directive <a href="sybase.configuration.html#ini.magic-quotes-sybase" class="link">   magic_quotes_sybase</a> set to <i>on</i> will mean   <i>&#039;</i> is instead escaped with another   <i>&#039;</i>.  </p>  <p class="para">   The PHP directive <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">   magic_quotes_gpc</a> is <i>on</i> by default, and it   essentially runs <b>addslashes()</b> on all GET, POST,   and COOKIE data.  Do not use <b>addslashes()</b> on   strings that have already been escaped with   <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a> as you&#039;ll   then do double escaping.  The function   <a href="function.get-magic-quotes-gpc.html" class="function">get_magic_quotes_gpc()</a> may come in handy for   checking this.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">str</tt></i></span>     <dd>      <p class="para">       The string to be escaped.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns the escaped string.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 An <b>addslashes()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Is&nbsp;your&nbsp;name&nbsp;O'reilly?"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Outputs:&nbsp;Is&nbsp;your&nbsp;name&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">$str</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div>  <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.stripcslashes.html" class="function" rel="rdfs-seeAlso">stripcslashes()</a></li>    <li class="member"><a href="function.stripslashes.html" class="function" rel="rdfs-seeAlso">stripslashes()</a></li>    <li class="member"><a href="function.addcslashes.html" class="function" rel="rdfs-seeAlso">addcslashes()</a></li>    <li class="member"><a href="function.htmlspecialchars.html" class="function" rel="rdfs-seeAlso">htmlspecialchars()</a></li>    <li class="member"><a href="function.quotemeta.html" class="function" rel="rdfs-seeAlso">quotemeta()</a></li>    <li class="member"><a href="function.get-magic-quotes-gpc.html" class="function" rel="rdfs-seeAlso">get_magic_quotes_gpc()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.addcslashes.html">addcslashes</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.bin2hex.html">bin2hex</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

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