<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.addcslashes.php',
    1 => 'addcslashes',
    2 => 'Quote string with slashes in a C style',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'next' => 
  array (
    0 => 'function.addslashes.php',
    1 => 'addslashes',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/addcslashes.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.addcslashes" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">addcslashes</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</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" id="refsect1-function.addcslashes-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>addcslashes</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$characters</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Returns a string with backslashes before characters that are
   listed in <code class="parameter">characters</code> parameter. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.addcslashes-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The string to be escaped.
      </p>
     </dd>
    
    
     <dt><code class="parameter">characters</code></dt>
     <dd>
      <p class="para">
       A list of characters to be escaped. If
       <code class="parameter">characters</code> contains characters
       <code class="literal">\n</code>, <code class="literal">\r</code> 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 <code class="parameter">characters</code> 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="example" id="example-1">
        <p><strong>Приклад #1 <span class="function"><strong>addcslashes()</strong></span> with Ranges</strong></p>
        <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo[ ]'</span><span style="color: #007700">, </span><span style="color: #DD0000">'A..z'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// output:  \f\o\o\[ \]<br />// All upper and lower-case letters will be escaped<br />// ... but so will the [\]^_`<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 <span class="function"><a href="function.ord.php" class="function">ord()</a></span> function to find the
       ASCII value for a character.
       <div class="example" id="example-2">
        <p><strong>Приклад #2 <span class="function"><strong>addcslashes()</strong></span> with Characters in Wrong Order</strong></p>
        <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #DD0000">"zoo['.']"</span><span style="color: #007700">, </span><span style="color: #DD0000">'z..A'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// output:  \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, all of
       which are predefined escape sequences in C. Many of these sequences are
       also defined in other C-derived languages, including PHP, meaning that
       you may not get the desired result if you use the output of
       <span class="function"><strong>addcslashes()</strong></span> to generate code in those languages
       with these characters defined in <code class="parameter">characters</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.addcslashes-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the escaped string.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.addcslashes-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
    <code class="parameter">characters</code> like &quot;\0..\37&quot;, which would
    escape all characters with ASCII code between 0 and 31.
   <div class="example" id="example-3">
    <p><strong>Приклад #3 <span class="function"><strong>addcslashes()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$not_escaped </span><span style="color: #007700">= </span><span style="color: #DD0000">"PHP isThirty\nYears Old!\tYay to the Elephant!\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$escaped </span><span style="color: #007700">= </span><span style="color: #0000BB">addcslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$not_escaped</span><span style="color: #007700">, </span><span style="color: #DD0000">"\0..\37!@\177..\377"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$escaped</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.addcslashes-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.stripcslashes.php" class="function" rel="rdfs-seeAlso">stripcslashes()</a> - Un-quote string quoted with addcslashes</span></li>
    <li><span class="function"><a href="function.stripslashes.php" class="function" rel="rdfs-seeAlso">stripslashes()</a> - Un-quotes a quoted string</span></li>
    <li><span class="function"><a href="function.addslashes.php" class="function" rel="rdfs-seeAlso">addslashes()</a> - Quote string with slashes</span></li>
    <li><span class="function"><a href="function.htmlspecialchars.php" class="function" rel="rdfs-seeAlso">htmlspecialchars()</a> - Convert special characters to HTML entities</span></li>
    <li><span class="function"><a href="function.quotemeta.php" class="function" rel="rdfs-seeAlso">quotemeta()</a> - Quote meta characters</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>