Description
Mixed PathInfo (string $path [, int $options])
PathInfo () returns an associative array containing the information with path. Includes the following array cells: dirname,basename and extension.
You can specify which cells to return through the parameter options. They include: Pathinfo_dirname,pathinfo_basename and Pathinfo_extension. The default is to return all the cells. This function returns a string if all the cells are not required to be obtained.
Example #1 PathInfo () example
The code is as follows |
Copy Code |
<?php $path _parts = PathInfo ("/www/htdocs/index.html"); echo $path _parts["DirName"]. ” “; echo $path _parts["basename"]. ” “; echo $path _parts["extension"]. ” “; ?> |
The above routines will output:
/www/htdocs
Index.html
htmlphp parse_url resolves the URL and returns its constituent
Parse_url
(PHP 4, PHP 5)
parse_url-resolves the URL and returns its components
Description
Array Parse_url (string $url) This function resolves a URL and returns an associative array containing the various components that appear in the URL.
This function is not used to verify the legality of a given URL, but to decompose it into the sections listed below. An incomplete URL is also accepted, and Parse_url () tries to parse it as correctly as possible.
Parameters
Url
The URL to resolve
return value
The severely unqualified url,parse_url () may return FALSE and emit e_warning. Otherwise, an associative array is returned, and its components are (at least one):
scheme-such as HTTP
Host
Port
User
Pass
Path
query-At the question mark? After
fragment-After the hash symbol #
Example
Example #1 Parse_url () example
The code is as follows |
Copy Code |
<?php $url = ' Http://username:password@hostname/path?arg=value#anchor '; Print_r (Parse_url ($url)); ?> |
The above routines will output:
Array
(
[Scheme] => http
[Host] => hostname
[User] => username
[Pass] => password
[Path] =>/path
[Query] => arg=value
[Fragment] => anchor
)
Comments
Note:
This function cannot be used for relative URLs.
1