05.1 Url Functions
Peter Ivanov edited this page Aug 20, 2013
·
1 revision
Functions to work with the url
Returns the site url
# http://www.yourwebsite.com/
print site_url();
# http://www.yourwebsite.com/my-link
print site_url('my-link');
# http://www.yourwebsite.com/api/user_login
print site_url('api/user_login');
Returns the url segments as array or string or false
# URL http://yoursite.com/blog/post-title
# get all segments
$segs =url_segment();
var_dump($segs);
# prints array(3) { [0]=> string(4) "blog" [1]=> string(10) "post-title" }
# get a single segment
$segs =url_segment(1);
var_dump($segs);
# prints string(4) "blog"
Returns the url sting of the current page
# url - yoursite.com/page/some-title/something
$url_path = url_path();
var_dump($url_path);
# prints - page/some-title/something
Get a parameter from the URL
# url - yoursite.com/page/my_param:my_value
# or url - yoursite.com/page/?my_param=my_value
$url_param = url_param('my_param');
var_dump($url_param);
# prints - "my_value"