JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • AbstractUri
  • Uri
  • UriHelper
  • UriImmutable

Interfaces

  • UriInterface
 1 <?php
 2 /**
 3  * Part of the Joomla Framework Uri Package
 4  *
 5  * @copyright  Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.
 6  * @license    GNU General Public License version 2 or later; see LICENSE
 7  */
 8 
 9 namespace Joomla\Uri;
10 
11 /**
12  * Uri Helper
13  *
14  * This class provides a UTF-8 safe version of parse_url().
15  *
16  * @since  1.0
17  */
18 class UriHelper
19 {
20     /**
21      * Does a UTF-8 safe version of PHP parse_url function
22      *
23      * @param   string  $url  URL to parse
24      *
25      * @return  mixed  Associative array or false if badly formed URL.
26      *
27      * @see     http://us3.php.net/manual/en/function.parse-url.php
28      * @since   1.0
29      */
30     public static function parse_url($url)
31     {
32         $result = false;
33 
34         // Build arrays of values we need to decode before parsing
35         $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D');
36         $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]");
37 
38         // Create encoded URL with special URL characters decoded so it can be parsed
39         // All other characters will be encoded
40         $encodedURL = str_replace($entities, $replacements, urlencode($url));
41 
42         // Parse the encoded URL
43         $encodedParts = parse_url($encodedURL);
44 
45         // Now, decode each value of the resulting array
46         if ($encodedParts)
47         {
48             foreach ($encodedParts as $key => $value)
49             {
50                 $result[$key] = urldecode(str_replace($replacements, $entities, $value));
51             }
52         }
53 
54         return $result;
55     }
56 }
57 
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.