_wp_translate_php_url_constant_to_key()WP 4.7.0

Translates a PHP_URL_* constant to the named array keys PHP uses.

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.

Returns

string|false. The named key or false.

Usage

_wp_translate_php_url_constant_to_key( $constant );
$constant(int) (required)
PHP_URL_* constant.

Changelog

Since 4.7.0 Introduced.

_wp_translate_php_url_constant_to_key() code WP 7.1

function _wp_translate_php_url_constant_to_key( $constant ) {
	$translation = array(
		PHP_URL_SCHEME   => 'scheme',
		PHP_URL_HOST     => 'host',
		PHP_URL_PORT     => 'port',
		PHP_URL_USER     => 'user',
		PHP_URL_PASS     => 'pass',
		PHP_URL_PATH     => 'path',
		PHP_URL_QUERY    => 'query',
		PHP_URL_FRAGMENT => 'fragment',
	);

	return $translation[ $constant ] ?? false;
}