<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pcre.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.preg-quote.php',
    1 => 'preg_quote',
    2 => 'Quote regular expression characters',
  ),
  'up' => 
  array (
    0 => 'ref.pcre.php',
    1 => 'Функції PCRE',
  ),
  'prev' => 
  array (
    0 => 'function.preg-match-all.php',
    1 => 'preg_match_all',
  ),
  'next' => 
  array (
    0 => 'function.preg-replace.php',
    1 => 'preg_replace',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcre/functions/preg-quote.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.preg-quote" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">preg_quote</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">preg_quote</span> &mdash; <span class="dc-title">Quote regular expression characters</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.preg-quote-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>preg_quote</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$str</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$delimiter</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>preg_quote()</strong></span> takes <code class="parameter">str</code>
   and puts a backslash in front of every character that is part of
   the regular expression syntax.  This is useful if you have a
   run-time string that you need to match in some text and the
   string may contain special regex characters.
  </p>
  <p class="para">
   The special regular expression characters are:
   <code class="literal">. \ + * ? [ ^ ] $ ( ) { } = ! &lt; &gt; | : - #</code>
  </p>
  <p class="para">
   Note that <code class="literal">/</code> is not a special regular expression character.
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Note that <span class="function"><strong>preg_quote()</strong></span> is not meant to be applied to the
    $replacement string(s) of <span class="function"><a href="function.preg-replace.php" class="function">preg_replace()</a></span> etc.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.preg-quote-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">str</code></dt>
     <dd>
      <p class="para">
       The input string.
      </p>
     </dd>
    
    
     <dt><code class="parameter">delimiter</code></dt>
     <dd>
      <p class="para">
       If the optional <code class="parameter">delimiter</code> is specified, it
       will also be escaped.  This is useful for escaping the delimiter
       that is required by the PCRE functions. The <code class="literal">/</code> is the most commonly
       used delimiter.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


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


 <div class="refsect1 changelog" id="refsect1-function.preg-quote-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>7.3.0</td>
       <td>
        The <code class="literal">#</code> character is now quoted
       </td>
      </tr>

      <tr>
       <td>7.2.0</td>
       <td>
        <code class="parameter">delimiter</code> is nullable now.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.preg-quote-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>preg_quote()</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 />$keywords </span><span style="color: #007700">= </span><span style="color: #DD0000">'$40 for a g3/400'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$keywords </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_quote</span><span style="color: #007700">(</span><span style="color: #0000BB">$keywords</span><span style="color: #007700">, </span><span style="color: #DD0000">'/'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$keywords</span><span style="color: #007700">; </span><span style="color: #FF8000">// returns \$40 for a g3\/400<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Приклад #2 Italicizing a word within some text</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: #FF8000">// In this example, preg_quote($word) is used to keep the<br />// asterisks from having special meaning to the regular<br />// expression.<br /><br /></span><span style="color: #0000BB">$textbody </span><span style="color: #007700">= </span><span style="color: #DD0000">"This book is *very* difficult to find."</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$word </span><span style="color: #007700">= </span><span style="color: #DD0000">"*very*"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$textbody </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_replace </span><span style="color: #007700">(</span><span style="color: #DD0000">"/" </span><span style="color: #007700">. </span><span style="color: #0000BB">preg_quote</span><span style="color: #007700">(</span><span style="color: #0000BB">$word</span><span style="color: #007700">, </span><span style="color: #DD0000">'/'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"/"</span><span style="color: #007700">,<br />                          </span><span style="color: #DD0000">"&lt;i&gt;" </span><span style="color: #007700">. </span><span style="color: #0000BB">$word </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;/i&gt;"</span><span style="color: #007700">,<br />                          </span><span style="color: #0000BB">$textbody</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.preg-quote-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: <span class="simpara">Ця функція є бінарно
безпечною.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.preg-quote-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="pcre.pattern.php" class="link">PCRE Patterns</a></li>
    <li><span class="function"><a href="function.escapeshellcmd.php" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - Escape shell metacharacters</span></li>
   </ul>
  </p>
 </div>


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