Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5413

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Returns the error code of the last PCRE regex execution</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.preg-grep.html">preg_grep</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.preg-match-all.html">preg_match_all</a></div>
 <div class="up"><a href="ref.pcre.html">PCRE Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.preg-last-error" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">preg_last_error</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0)</p><p class="refpurpose"><span class="refname">preg_last_error</span> &mdash; <span class="dc-title">Returns the error code of the last PCRE regex execution</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.preg-last-error-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>preg_last_error</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Returns the error code of the last PCRE regex execution.
  </p>
  <p class="para">
   <div class="example" id="example-4784">
    <p><strong>Example #1  <span class="function"><strong>preg_last_error()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/(?:\D+|&lt;\d+&gt;)*[!?]/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'foobar&nbsp;foobar&nbsp;foobar'</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">preg_last_error</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #0000BB">PREG_BACKTRACK_LIMIT_ERROR</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">'Backtrack&nbsp;limit&nbsp;was&nbsp;exhausted!'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Backtrack limit was exhausted!
</pre></div>
    </div>
   </div>
  </p>
 </div>

  
 <div class="refsect1 returnvalues" id="refsect1-function.preg-last-error-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns one of the following constants (<a href="pcre.constants.html" class="link">explained on their own page</a>):
   <ul class="simplelist">
    <li class="member"><strong><code>PREG_NO_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_INTERNAL_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_BACKTRACK_LIMIT_ERROR</code></strong> (see also <a href="pcre.configuration.html#ini.pcre.backtrack-limit" class="link">pcre.backtrack_limit</a>)</li>
    <li class="member"><strong><code>PREG_RECURSION_LIMIT_ERROR</code></strong> (see also <a href="pcre.configuration.html#ini.pcre.recursion-limit" class="link">pcre.recursion_limit</a>)</li>
    <li class="member"><strong><code>PREG_BAD_UTF8_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_BAD_UTF8_OFFSET_ERROR</code></strong> (since PHP 5.3.0)</li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.preg-grep.html">preg_grep</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.preg-match-all.html">preg_match_all</a></div>
 <div class="up"><a href="ref.pcre.html">PCRE Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>