note 99884 added to pcre.constants
| From: | Andrew at osu1 dot php dot net | Date: | Mon, 13 Sep 2010 00:30:45 +0000 |
| Subject: | note 99884 added to pcre.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172503@lists.php.net to get a copy of this message | ||
This is an edit to the note by Bastiaan.
I corrected the spelling of "decode" in the function name, and I removed references to
non-error constants, per the editor's note. I also changed all "print"s to
"return"s in line with more standard programming techniques.
<?php
function pcre_error_decode() {
switch (preg_last_error()) {
case PREG_NO_ERROR:
// do not print in this case
//return "Returned by preg_last_error() if there were no errors. Available since PHP
5.2.0.\n";
break;
case PREG_INTERNAL_ERROR:
return "Returned by preg_last_error() if there was an internal PCRE error. Available
since PHP 5.2.0.\n";
break;
case PREG_BACKTRACK_LIMIT_ERROR:
return "Returned by preg_last_error() if backtrack limit was exhausted. Available
since PHP 5.2.0.\n";
break;
case PREG_RECURSION_LIMIT_ERROR:
return "Returned by preg_last_error() if recursion limit was exhausted. Available
since PHP 5.2.0.\n";
break;
case PREG_BAD_UTF8_ERROR:
return "Returned by preg_last_error() if the last error was caused by malformed UTF-8
data (only when running a regex in UTF-8 mode). Available since PHP 5.2.0.\n";
break;
case PREG_BAD_UTF8_OFFSET_ERROR:
return "Returned by preg_last_error() if the offset didn't correspond to the
begin of a valid UTF-8 code point (only when running a regex in UTF-8 mode). Available since PHP
5.3.0.\n";
break;
}
}
// Usage:
// Insert preg_* expression here
echo "PREG ERROR: ".pcre_error_decode();
?>
----
Server IP: 208.69.120.55
Probable Submitter: 24.171.159.176
----
Manual Page -- http://www.php.net/manual/en/pcre.constants.php
Edit -- https://master.php.net/note/edit/99884
Del: integrated -- https://master.php.net/note/delete/99884/integrated
Del: useless -- https://master.php.net/note/delete/99884/useless
Del: bad code -- https://master.php.net/note/delete/99884/bad+code
Del: spam -- https://master.php.net/note/delete/99884/spam
Del: non-english -- https://master.php.net/note/delete/99884/non-english
Del: in docs -- https://master.php.net/note/delete/99884/in+docs
Del: other reasons-- https://master.php.net/note/delete/99884
Reject -- https://master.php.net/note/reject/99884
Search -- https://master.php.net/manage/user-notes.php