---
title: "[PRE-RFC] PREG_THROW_ON_ERROR flag"
url: https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-pdbwglgo0
source_url: https://externals.io/message/131801
type: article
source: "externals.io"
published: 2026-07-07T21:11:24.913Z
updated: 2026-07-07T21:11:46.166Z
tags: ["php"]
reading_time: 4
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# [PRE-RFC] PREG_THROW_ON_ERROR flag

**[externals.io](https://daily.dev/sources/externals)** · 4 min read · 0 upvotes · 0 comments

## Summary

A pre-RFC proposal to the PHP internals mailing list suggests adding a `PREG_THROW_ON_ERROR` flag to all `preg_*()` functions. Currently, PCRE errors in PHP either emit a warning and return `false`, or silently fail and require a follow-up `preg_last_error()` call to detect. The proposed flag would make any PCRE failure throw a `Pcre\PcreException` carrying the error code and message, consistent with how `JSON_THROW_ON_ERROR` and `FILTER_THROW_ON_FAILURE` work for their respective extensions. The author has completed a full implementation and is seeking community interest and feedback on two design questions: whether to throw on the first failing array element, and whether `_ON_ERROR` or `_ON_FAILURE` is the better naming convention.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://externals.io/message/131801>

## Similar posts on daily.dev

- [\[PRE-RFC\] PREG\_THROW\_ON\_ERROR flag](https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] Case sensitive PHP](https://daily.dev/posts/rfc-case-sensitive-php-tglu5yzre) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] Case sensitive PHP](https://daily.dev/posts/rfc-case-sensitive-php-k7dunim5d) · externals.io · 0 upvotes · 0 comments
- [\[PRE-RFC\] Deprecate returning from a finally block](https://daily.dev/posts/pre-rfc-deprecate-returning-from-a-finally-block-oiovloynx) · externals.io · 1 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php)

[View this post on daily.dev](https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-pdbwglgo0)
