| |
PHP Useful functions (Part 2) - The currentURL function
|
|
Tutorials >
Web Development >
PHP >
Resources >
PHP Useful functions (Part 2) - The currentURL function
|
|
Discuss this tutorial here |
Search www.geeksww.com for more tutorials here
|
|
Developing websites, social applications, and scripts in PHP for more than 6 years now, I found a number of utility functions helpful in development. I am going to write a series of tutorials writing such functions and describing their use. Using these functions I have created a library of dynamically loadable classes but you are free to use them as you wish.
The currentURL Function:
I am going to discuss the currentURL function here. Here is the function header:
function currentURL()
As can be seen the function takes no arguments but only returns the URL of the web page.
Usage:
I use this function wherever I need the URL of the current page. One example is the social bookmark links.
Function Definition:
Here is the definition of the function,
function currentURL()
{
return "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
Note: this function does not give you the query string. It just gives you the URL. If you want the query string too then append the following variable in the URL.
$_SERVER['QUERY_STRING']
|
|
| |
|
Discuss this tutorial here |
Search www.geeksww.com for more tutorials here
|
| |
Similar Tutorials:
|
| |
Support Geeks Worldwide:Link to us:
You can support us by putting a link to our website on your blog or website (code is below).
<a href="http://www.geeksww.com/">
Geeks Worldwide - Tutorials about Software Installation,
Configuration, Administration, Monitoring, Tools, Tips &
Tricks
</a>
OR a simple one.
<a href="http://www.geeksww.com/">
Geeks Worldwide - IT related Tutorials
</a>
Feedbacks: We appreciate feedbacks and suggestions about our tutorials and Geeks Worldwide from readers. Please contact us using the form here and let us know what you think about the tutorial and the website in general.
Bookmark Us:
We are working on new features for the website, please keep visiting or bookmark us using your favourite bookmarking service.
Subscribe to RSS:
You can subscribe to our RSS feed here.
|
| |