note 130651 added to filter.constants
| From: | steven@nevvix.com | Date: | Sat, 14 Feb 2026 04:22:05 +0000 |
| Subject: | note 130651 added to filter.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-222549@lists.php.net to get a copy of this message | ||
We can add FILTER_FLAG_EMPTY_STRING_NULL:
<?php
- function filter_sanitize_string(mixed $value, int $flags = 0): string|false {
+ function filter_sanitize_string(mixed $value, int $flags = 0): string|false|null {
+ if ($flags & FILTER_FLAG_EMPTY_STRING_NULL && $value === "") {
+ return null;
+ }
?>
For FILTER_FLAG_STRIP_BACKTICK, there is a bug history
(https://bugs.php.net/bug.php?id=69202)
so I did not attempt to code compatility through version history.
----
Server IP: 206.189.2.9
Probable Submitter: 2604:3d08:5e7b:f300:649d:ed01:f6c5:7ae7
----
Manual Page -- https://php.net/manual/en/filter.constants.php
Edit -- https://main.php.net/note/edit/130651
Del: integrated -- https://main.php.net/note/delete/130651/integrated
Del: useless -- https://main.php.net/note/delete/130651/useless
Del: bad code -- https://main.php.net/note/delete/130651/bad+code
Del: spam -- https://main.php.net/note/delete/130651/spam
Del: non-english -- https://main.php.net/note/delete/130651/non-english
Del: in docs -- https://main.php.net/note/delete/130651/in+docs
Del: other reasons-- https://main.php.net/note/delete/130651
Reject -- https://main.php.net/note/reject/130651
Search -- https://main.php.net/manage/user-notes.php