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

📄 function.addcslashes.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 in a C style</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="ref.strings.html">String Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.addslashes.html">addslashes</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.addcslashes" class="refentry"> <div class="refnamediv">  <h1 class="refname">addcslashes</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">addcslashes</span> &mdash; <span class="dc-title">Quote string with slashes in a C style</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>addcslashes</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$charlist</tt></span>   )</div>  <p class="para rdfs-comment">   Returns a string with backslashes before characters that are   listed in <i><tt class="parameter">charlist</tt></i> parameter.   </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>    <dt>     <span class="term"><i><tt class="parameter">charlist</tt></i></span>     <dd>      <p class="para">       A list of characters to be escaped. If       <i><tt class="parameter">charlist</tt></i> contains characters       <i>\n</i>, <i>\r</i> etc., they are       converted in C-like style, while other non-alphanumeric characters       with ASCII codes lower than 32 and higher than 126 converted to       octal representation.      </p>       <p class="para">        When you define a sequence of characters in the charlist argument        make sure that you know what characters come between the        characters that you set as the start and end of the range.        <div class="informalexample">         <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo[&nbsp;]'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'A..z'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;output:&nbsp;&nbsp;\f\o\o\[&nbsp;\]<br />//&nbsp;All&nbsp;upper&nbsp;and&nbsp;lower-case&nbsp;letters&nbsp;will&nbsp;be&nbsp;escaped<br />//&nbsp;...&nbsp;but&nbsp;so&nbsp;will&nbsp;the&nbsp;[\]^_`&nbsp;and&nbsp;any&nbsp;tabs,&nbsp;line<br />//&nbsp;feeds,&nbsp;carriage&nbsp;returns,&nbsp;etc.<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>         </div>        </div>        Also, if the first character in a range has a higher ASCII value        than the second character in the range, no range will be        constructed.  Only the start, end and period characters will be        escaped. Use the <a href="function.ord.html" class="function">ord()</a> function to find the        ASCII value for a character.        <div class="informalexample">         <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #DD0000">"zoo['.']"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'z..A'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;output:&nbsp;&nbsp;\zoo['\.']<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>         </div>        </div>       </p>       <p class="para">        Be careful if you choose to escape characters 0, a, b, f, n, r,        t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t        and \v.        In PHP \0 (NULL), \r (carriage return), \n (newline), \f (form feed),        \v (vertical tab) and \t (tab) are predefined escape sequences,         while in C all of these are predefined escape sequences.       </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 changelog">  <h3 class="title">ChangeLog</h3>  <p class="para">   <table class="informaltable">    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Version</th>       <th colspan="1">Description</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">5.2.5</td>       <td colspan="1" rowspan="1" align="left">        The escape sequences \v and \f were added.       </td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <i><tt class="parameter">charlist</tt></i> like &quot;\0..\37&quot;, which would   escape all characters with ASCII code between 0 and 31.   <div class="example">    <p><b>Example #1 <b>addcslashes()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$escaped&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$not_escaped</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"\0..\37!@\177..\377"</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.addslashes.html" class="function" rel="rdfs-seeAlso">addslashes()</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>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.strings.html">String Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.addslashes.html">addslashes</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 + -