This helper is loaded using the following code:
$this->load->helper('url');
URL Helper
See the below table, you will get the list of URL helper function of codeigniter with the output url like anchor link, popup window etc
URL Helper Function | Output URL |
---|---|
site_url () | http://127.0.0.1/codeigniter/first/index.php |
site_url (‘blog’) | http://127.0.0.1/codeigniter/first/index.php/blog |
site_url (‘blog/id/123’) | http://127.0.0.1/codeigniter/first/index.php/blog/id/123 |
$segments = array(‘blog’, ‘post’, ‘123’);
echo site_url ($segments) |
http://127.0.0.1/codeigniter/first/index.php/blog/post/123 |
base_url () | http://127.0.0.1/codeigniter/first/ |
base_url (“blog/post/123”) | http://127.0.0.1/codeigniter/first/blog/post/123 |
base_url (“/templates/images/icons/user.png”) | http://127.0.0.1/codeigniter/first/templates/images/icons/user.png |
current_url () | http://127.0.0.1/codeigniter/first/index.php/blog/post |
uri_string () | blog/post |
index_page () | index.php |
redirect(‘/blog’) | http://127.0.0.1/codeigniter/first/index.php/blog |
anchor() | <a href=”http://127.0.0.1/codeigniter/first/index.php”> http://127.0.0.1/codeigniter/first/index.php </a> |
anchor(“blog/post/123”) |
<a href=”http://127.0.0.1/codeigniter/first/index.php/blog/post/123″> |
echo anchor (‘blog/post/123’, ‘Post’, ‘title=”My Post”‘) | <a title=”My Post” href=”http://127.0.0.1/codeigniter/first/index.php/blog/post/123″> Post </a> |
$atts = array(
‘width’ => ‘800’, ‘height’ => ‘600’, ‘scrollbars’ => ‘yes’, ‘status’ => ‘yes’, ‘resizable’ => ‘yes’, ‘screenx’ => ‘0’, ‘screeny’ => ‘0’ ); echo anchor_popup (‘blog/post/123’, ‘Click Me!’, $atts) |
<a onclick=”window.open(‘http://127.0.0.1/codeigniter/first/index.php/blog/post/123’, ‘_blank’, ‘width=800,height=600,scrollbars=yes,status=yes,resizable=yes,screenx=0,screeny=0’);” href=”javascript:void(0);”> Click Me! </a> |
mailto (‘[email protected]’, ‘Mail Me’) | <a href=”mailto:[email protected]”>Mail Me</a> |
$url = “domain.com”;
echo $url = prep_url($url) |
http://domain.com |