parse_url and pathinfo

parse_url and pathinfo

parse_url:
=======

parse_url
- It parse a URL and return its components

Syntax:
=====
array parse_url ( string url)

This function returns an associative array returning any of the various components of the URL that are present. This includes the

scheme - e.g. http://

host

port

user

pass

path

query - after the question mark ?

fragment - after the hashmark #

Example:
======

parse_url(”http://www.sample.com/index.php?input=name”);

Output is:

Array
(
[scheme] => http
[host] => www.sample.com
[path] => /index.php
[query] => input=name
)

====================================================================

pathinfo:
======

pathinfo
- It returns information about a file path

Syntax:
=====
array pathinfo ( string path)

pathinfo() returns an associative array containing information about path.
The following array elements are returned: dirname, basename and extension.

Example:
======

pathinfo(”http://www.sample.com/index.php?input=name”);

Output is:

Array
(
[dirname] => http://www.sample.com
[basename] => index.php?input=name
[extension] => php?input=name
)

====================================================================

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.