What is URL Helper in codeigniter - What is Helper in Codeigniter - Codeigniter tutorial for beginners step by step in hindi
URL Helper in codeigniter
The URL Helper file contains functions that assist in working with URLs.
How To Load URL Helper
There are Two way for load URL Helper in codeigniter
1.load on __constructor() :
Example
Class ControllerName extends CI_Controller
{
public function __constructor()
{
$this->load->helper('url');
}
}
2. Load On autoload.php
1.Go To Application/config/
2.Open autoload.php
3.$autoload['helper'] = array('url');
Function of url helper
- base_url();
- site_url ();
- current_url ();
- uri_string ();
- index_page ();
- redirect();
- anchor();
- mailto();
1.base_url :
This function use for get base_url of website . this url not content index.php You will need to set your base URL in application/config/config.php
Example :
ImageController.php
Class ImageController extends CI_Controller
{
public function __constructor()
{
$this->load->helper('url');
}
public function index()
{
$this->load->view('load_image');
}
}
load_image.php
<html>
<head>
<title>Load Image</title>
</head>
<body>
<?php echo base_url('assets/image/img1.jpg'); ?>
</body>
</html>
Output
http://xyz.com/blog/comment
2.site_url() :
This function use for get site_url of website . this url content index.php
ImageController.php
Class ImageController extends CI_Controller
{
public function __constructor()
{
$this->load->helper('url');
}
public function index()
{
$this->load->view('view_file');
}
}
View_file.php
<html>
<head>
<title>Load Image</title>
</head>
<body>
echo site_url("blog/comment");
</body>
</html>
Output :
http://xyz.com/index.php/blog/comment
3.current_url() :
This function use for get active url of website
4.uri_string() :
This function Returns the URI segments of any page that contains this function
5.index_page() :
This function Returns your site "index" page, as specified in your config file
6.redirect() :
This function use for redirect on page to other page
7.anchor() :
This function use for Creates a standard HTML anchor link
8.mailto() :
This function use for Creates a standard HTML email link
Related Tutorials
Tutorial Topics
- Intorducation of Codeigniter Tutorial - Codeigniter Tutorial For Beginners Step By Step in Hindi
- What is Codeigniter And What Is Framework - Codeigniter Tutorial For Beginners Step By Step in Hindi
- how to install codeigniter in xampp windows -Codeigniter Tutorial For Beginners Step by Step in Hindi
- Codeigniter Application Architecture - Codeigniter Directory Structure-Codeigniter Tutorial for Beginners Step by Step in Hindi
- What is MVC Architecture - Codeigniter Tutorial for Beginners Step by Step in Hindi
- Basic Component Of Codeigniter - Codeigniter tutorial for beginners step by step in hindi
- How to set Base url in Codeigniter Config File| Codeigniter tutorial for beginners step by step in hindi
- Database Configuration in Codeigniter |Codeigniter tutorial for beginners step by step in hindi
- How to Load Library | Model | Helper in Codeigniter | Autoload files | Codeigniter tutorial for beginners step by step in hindi
- How to Remove Index.PHP in Codeigniter using htaccess - Codeigniter tutorial for beginners step by step in hindi
- What is Helper in Codeigniter - Codeigniter tutorial for beginners step by step in hindi
- What is URL Helper in codeigniter - What is Helper in Codeigniter - Codeigniter tutorial for beginners step by step in hindi