jetpack_photon_parse_url

A wrapper for PHP's parse_url, prepending assumed scheme for network path URLs.

Description

jetpack_photon_parse_url( (string) $url, (int) $component = -1 ); 

PHP versions 5.4.6 and earlier do not correctly parse without scheme.

Parameters (2)

0. $url (string)
The URL to parse
1. $component — Optional. (int) => -1
Retrieve specific URL component

Usage

  1. if ( !function_exists( 'jetpack_photon_parse_url' ) ) { 
  2. require_once '/functions.photon.php'; 
  3.  
  4. // The URL to parse 
  5. $url = ''; 
  6.  
  7. // Retrieve specific URL component 
  8. $component = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = jetpack_photon_parse_url($url, $component); 
  12.  

Defined (1)

The function is defined in the following location(s).

/functions.photon.php  
  1. function jetpack_photon_parse_url( $url, $component = -1 ) { 
  2. if ( 0 === strpos( $url, '//' ) ) { 
  3. $url = ( is_ssl() ? 'https:' : 'http:' ) . $url; 
  4.  
  5. return parse_url( $url, $component );