Accepted. Voting closed on March 6, 2026 with 25 in favor and 0 against, above the two-thirds majority it needed. It shipped in PHP 8.6.
Adds the form feed character (\f) to the default set of characters that trim(), ltrim() and rtrim() strip.
This poll has closed.
Accepted. Voting closed on March 6, 2026 with 25 in favor and 0 against, above the two-thirds majority it needed. It shipped in PHP 8.6.
When you call trim(), ltrim() or rtrim() without a second argument, they strip a default set of characters: space, tab, newline, carriage return, the NUL byte and the vertical tab. The form feed, "\f", isn't on that list. This RFC from Weilin Du adds it.
The RFC points out that \f is already treated as whitespace in plenty of places. The C function isspace(), which PHP uses internally, counts it, and so does PHP's own is_numeric(). Python, JavaScript, Rust and Go all strip it in their trim functions.
$str = "\fHello World\f"; var_dump(trim($str)); // Before // string(13) "\fHello World\f" // After // string(11) "Hello World"
Only the default changes. If you pass your own list of characters, you get exactly what you asked for.
This is a backward compatibility break, but a small one. It only affects code that relies on trim() keeping a form feed at the start or end of a string.
A few tools need updates:
\f in their tooltips for these functions.trim("\f") now returns an empty string.Other trim-like behavior, such as PHP's filters, isn't part of this RFC. The RFC also notes that removing the NUL byte from the default list could be a separate RFC someday.