_wp_can_use_pcre_u()WP 4.2.2

Returns whether PCRE/u (PCRE_UTF8 modifier) is available for use.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

null. Nothing (null).

Usage

_wp_can_use_pcre_u( $set );
$set(true|false)
- Used for testing only null : default - get PCRE/u capability false : Used for testing - return false for future calls to this function 'reset': Used for testing - restore default behavior of this function
Default: null

Changelog

Since 4.2.2 Introduced.

_wp_can_use_pcre_u() code WP 6.5.2

function _wp_can_use_pcre_u( $set = null ) {
	static $utf8_pcre = 'reset';

	if ( null !== $set ) {
		$utf8_pcre = $set;
	}

	if ( 'reset' === $utf8_pcre ) {
		// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentional error generated to detect PCRE/u support.
		$utf8_pcre = @preg_match( '/^./u', 'a' );
	}

	return $utf8_pcre;
}