<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a" -->

---
title: [PRE-RFC] PREG_THROW_ON_ERROR flag | daily.dev
description: A pre-RFC proposal to the PHP internals mailing list suggests adding a PREG_THROW_ON_ERROR flag to all preg_*() functions. Following the pattern of...
canonical: https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: [PRE-RFC] PREG_THROW_ON_ERROR flag | daily.dev
og:description: A pre-RFC proposal to the PHP internals mailing list suggests adding a PREG_THROW_ON_ERROR flag to all preg_*() functions. Following the pattern of...
og:url: https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a
og:image: https://api.daily.dev/og/posts/Y0GMmhO0A.png
og:image:alt: [PRE-RFC] PREG_THROW_ON_ERROR flag
og:image:width: 1200
og:image:height: 630
og:locale: 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)** · 2 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. Following the pattern of JSON_THROW_ON_ERROR and FILTER_THROW_ON_FAILURE, this flag would make PCRE errors throw a Pcre\PcreException instead of silently returning false or emitting warnings. It would cover both compilation errors (malformed patterns) and execution errors (e.g., bad UTF-8). The proposal also includes adding an optional $flags parameter to preg_replace() and preg_filter(), which currently lack one. Two open design questions are raised: whether to throw on the first failing array element rather than last-one-wins, 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/131783>

## Similar posts on daily.dev

- [\[RFC\] Case sensitive PHP](https://daily.dev/posts/rfc-case-sensitive-php-tglu5yzre) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] Deprecations for PHP 8.6](https://daily.dev/posts/rfc-deprecations-for-php-8-6-6rzkdqyuf) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] Pattern Matching](https://daily.dev/posts/rfc-pattern-matching-dna1xznxx) · externals.io · 4 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-y0gmmho0a)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"[PRE-RFC] PREG_THROW_ON_ERROR flag","url":"https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a"},"datePublished":"2026-07-07T01:28:04.597Z","dateModified":"2026-07-07T01:28:25.642Z","description":"A pre-RFC proposal to the PHP internals mailing list suggests adding a PREG_THROW_ON_ERROR flag to all preg_*() functions. Following the pattern of...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"externals.io","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"externals.io","logo":"https://media.daily.dev/image/upload/s--9i0zxASK--/f_auto,q_auto/v1780213616/logos/externals?_a=BAMAMiWQ0","url":"https://daily.dev/sources/externals"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/pre-rfc-preg-throw-on-error-flag-y0gmmho0a","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"php","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"externals.io","item":"https://daily.dev/sources/externals"},{"@type":"ListItem","position":3,"name":"[PRE-RFC] PREG_THROW_ON_ERROR flag"}]}
```

