Title: _wp_translate_php_url_constant_to_key
Published: December 7, 2016
Last modified: August 20, 2026

---

# _wp_translate_php_url_constant_to_key( int $constant ): string|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#parameters)󠁿

 `$constant`intrequired

PHP*URL** constant.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#return)󠁿

 string|false The named key or false.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#source)󠁿

    ```php
    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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/http.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/http.php#L867)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/http.php#L867-L880)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#related)󠁿

| Used by | Description | 
| [_get_component_from_parsed_url_array()](https://developer.wordpress.org/reference/functions/_get_component_from_parsed_url_array/)`wp-includes/http.php` |

Retrieves a specific component from a parsed URL array.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_translate_php_url_constant_to_key/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_translate_php_url_constant_to_key%2F)
before being able to contribute a note or feedback.