Skip to content

Commit 3ec7b61

Browse files
committed
Add preg_last_error_msg documentation
Patch contributed by Nicolas Oelgart <[email protected]>. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350809 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 9418329 commit 3ec7b61

File tree

4 files changed

+104
-2
lines changed

4 files changed

+104
-2
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<refentry xml:id="function.preg-last-error-msg" xmlns="http://docbook.org/ns/docbook">
4+
<refnamediv>
5+
<refname>preg_last_error_msg</refname>
6+
<refpurpose>Returns the error message of the last PCRE regex execution</refpurpose>
7+
</refnamediv>
8+
9+
<refsect1 role="description">
10+
&reftitle.description;
11+
<methodsynopsis>
12+
<type>string</type><methodname>preg_last_error_msg</methodname>
13+
<void />
14+
</methodsynopsis>
15+
<para>
16+
Returns the error message of the last PCRE regex execution.
17+
</para>
18+
</refsect1>
19+
20+
<refsect1 role="parameters">
21+
&reftitle.parameters;
22+
&no.function.parameters;
23+
</refsect1>
24+
25+
<refsect1 role="returnvalues">
26+
&reftitle.returnvalues;
27+
<para>
28+
Returns the error message on success, or <literal>"No error"</literal> if no
29+
error has occurred.
30+
</para>
31+
</refsect1>
32+
33+
<refsect1 role="examples">
34+
&reftitle.examples;
35+
<para>
36+
<example>
37+
<title><function>preg_last_error_msg</function> example</title>
38+
<programlisting role="php">
39+
<![CDATA[
40+
<?php
41+
42+
preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
43+
44+
if (preg_last_error() !== PREG_NO_ERROR) {
45+
echo preg_last_error_msg();
46+
}
47+
48+
?>
49+
]]>
50+
</programlisting>
51+
&example.outputs;
52+
<screen>
53+
<![CDATA[
54+
Backtrack limit exhausted
55+
]]>
56+
</screen>
57+
</example>
58+
</para>
59+
</refsect1>
60+
61+
<refsect1 role="seealso">
62+
&reftitle.seealso;
63+
<para>
64+
<simplelist>
65+
<member><function>preg_last_error</function></member>
66+
</simplelist>
67+
</para>
68+
</refsect1>
69+
70+
</refentry>
71+
72+
<!-- Keep this comment at the end of the file
73+
Local variables:
74+
mode: sgml
75+
sgml-omittag:t
76+
sgml-shorttag:t
77+
sgml-minimize-attributes:nil
78+
sgml-always-quote-attributes:t
79+
sgml-indent-step:1
80+
sgml-indent-data:t
81+
indent-tabs-mode:nil
82+
sgml-parent-document:nil
83+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
84+
sgml-exposed-tags:nil
85+
sgml-local-catalogs:nil
86+
sgml-local-ecat-files:nil
87+
End:
88+
vim600: syn=xml fen fdm=syntax fdl=2 si
89+
vim: et tw=78 syn=sgml
90+
vi: ts=1 sw=1
91+
-->

reference/pcre/functions/preg-last-error.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
2626
2727
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
28-
print 'Backtrack limit was exhausted!';
28+
echo 'Backtrack limit was exhausted!';
2929
}
3030
3131
?>
@@ -60,6 +60,15 @@ Backtrack limit was exhausted!
6060
</para>
6161
</refsect1>
6262

63+
<refsect1 role="seealso">
64+
&reftitle.seealso;
65+
<para>
66+
<simplelist>
67+
<member><function>preg_last_error_msg</function></member>
68+
</simplelist>
69+
</para>
70+
</refsect1>
71+
6372
</refentry>
6473

6574
<!-- Keep this comment at the end of the file

reference/pcre/functions/preg-match.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ Array
405405
<member><function>preg_replace</function></member>
406406
<member><function>preg_split</function></member>
407407
<member><function>preg_last_error</function></member>
408+
<member><function>preg_last_error_msg</function></member>
408409
</simplelist>
409410
</para>
410411
</refsect1>

reference/pcre/versions.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<function name='preg_filter' from='PHP 5 &gt;= 5.3.0, PHP 7'/>
88
<function name='preg_grep' from='PHP 4, PHP 5, PHP 7'/>
99
<function name='preg_last_error' from='PHP 5 &gt;= 5.2.0, PHP 7'/>
10+
<function name='preg_last_error_msg' from='PHP 8'/>
1011
<function name='preg_match' from='PHP 4, PHP 5, PHP 7'/>
1112
<function name='preg_match_all' from='PHP 4, PHP 5, PHP 7'/>
1213
<function name='preg_quote' from='PHP 4, PHP 5, PHP 7'/>
@@ -35,4 +36,4 @@ End:
3536
vim600: syn=xml fen fdm=syntax fdl=2 si
3637
vim: et tw=78 syn=sgml
3738
vi: ts=1 sw=1
38-
-->
39+
-->

0 commit comments

Comments
 (0)