The URL Helper
The URL Helper is a class, stored inside the 'engine' folder, that helps you to perform tasks related to page URLs. The following features are available inside the URL helper:
Purpose: Returns the URL of the current page.
$page_url = current_url();
Purpose: Returns the URL of the previously visited page. This is often called the referrer URL or the HTTP referer.
$previous_url = previous_url();
Purpose: Returns the base URL of your app. This is usually the URL corresponds with your web app's home page.
$homepage = BASE_URL;
Purpose: The segment getter helps you to easily fetch segments from the current page URL. A segment is a string of characters that occur in a URL. Segments are separated by forward-slashes.
Arguments: Accepts one argument: an integer representing the segment number that you would like to fetch.
If your URL was this,
then, the code below would assign a value of 'rock' to the $first_segment variable.
$first_segment = segment(1);
$var = $this->url->segment(3);
As you can see, the code being used today is a little more compact.
HELP & SUPPORT
If you have a question or a comment relating to anything you've see here, please goto the Help Bar.