note 102356 deleted from function.preg-last-error by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: asnyder at noloh dot com 

----

I thought this might be helpful for those that want to simply find out what error is being thrown without doing their own switch.

pcre_error_decode from Luminous, see http://luminous.googlecode.com/, GPL, http://www.gnu.org/licenses/

<?php

**
 * \ingroup LuminousUtils
 * \internal
 * \brief Decodes a PCRE error code into a string
 * \param errcode The error code to decode (integer)
 * \return A string which is simply the name of the constant which matches the
 *      error code (e.g. 'PREG_BACKTRACK_LIMIT_ERROR')
 */ 
function pcre_error_decode($errcode)
{
  switch ($errcode)
  {
    case PREG_NO_ERROR:
      return 'PREG_NO_ERROR';
    case PREG_INTERNAL_ERROR:
      return 'PREG_INTERNAL_ERROR';
    case PREG_BACKTRACK_LIMIT_ERROR:
      return 'PREG_BACKTRACK_LIMIT_ERROR';
    case PREG_RECURSION_LIMIT_ERROR:
      return 'PREG_RECURSION_LIMIT_ERROR';
    case PREG_BAD_UTF8_ERROR:
      return 'PREG_BAD_UTF8_ERROR';
    case PREG_BAD_UTF8_OFFSET_ERROR:
      return 'PREG_BAD_UTF8_OFFSET_ERROR';
    default:
      return 'Unknown error code';
  }
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.