SimplePie_Misc::parse_url PHP Method

parse_url() public method

public parse_url ( $url )
    function parse_url($url)
    {
        $iri = new SimplePie_IRI($url);
        return array('scheme' => (string) $iri->get_scheme(), 'authority' => (string) $iri->get_authority(), 'path' => (string) $iri->get_path(), 'query' => (string) $iri->get_query(), 'fragment' => (string) $iri->get_fragment());
    }

Usage Example

 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     if (class_exists('idna_convert')) {
         $idn = new idna_convert();
         $parsed = SimplePie_Misc::parse_url($url);
         $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
     }
     $this->url = $url;
     $this->useragent = $useragent;
     if (preg_match('/^http(s)?:\\/\\//i', $url)) {
         if (!is_array($headers)) {
             $headers = array();
         }
         $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
         $headers2 = array();
         foreach ($headers as $key => $value) {
             $headers2[] = "{$key}: {$value}";
         }
         //TODO: allow for HTTP headers
         // curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
         $response = self::$agent->get($url);
         if ($response === false || !isset($response['status_code'])) {
             $this->error = 'failed to fetch URL';
             $this->success = false;
         } else {
             // The extra lines at the end are there to satisfy SimplePie's HTTP parser.
             // The class expects a full HTTP message, whereas we're giving it only
             // headers - the new lines indicate the start of the body.
             $parser = new SimplePie_HTTP_Parser($response['headers'] . "\r\n\r\n");
             if ($parser->parse()) {
                 $this->headers = $parser->headers;
                 //$this->body = $parser->body;
                 $this->body = $response['body'];
                 $this->status_code = $parser->status_code;
             }
         }
     } else {
         $this->error = 'invalid URL';
         $this->success = false;
     }
 }
All Usage Examples Of SimplePie_Misc::parse_url