Changing in PHP 7.4

Now that WordPress is actively pushing the community and sites that run it toward more modern versions of PHP, it’s extra important to follow language changes. That’s where this summary of the most consequential features of the forthcoming PHP 7.4 for WordPress development form Jonathan Desrosiers comes in. He does a great job of quickly and approachably explaining all the features and changes that the language will bring.

I was happy to learn that none of the changes really affect code I typically write, but this change was the most striking to me. Mostly because it highlighted a weird ambiguity in the PHP API I wasn’t aware of:

Specific Parameter Order Requirements For implode()

The implode() function accepts two parameters, $glue and $pieces. For historical reasons, implode() has accepted these parameters in any order, though it has been a recommendation that the documented order of implode( $glue, $pieces ) be used.

Starting in PHP 7.4, tolerance for passing the parameters in reverse order is deprecated and will be completely removed in PHP 8.0. Calling implode( $pieces, $glue ) in PHP 7.4 will trigger a deprecated notice.

Add a Comment

Your email address will not be published. Required fields are marked *