Blog for Learning

This blog contains lesson material, material summary, questions and answers, definitions, types and examples, and others.

Advertisement

Powered by Blogger.

Visitors

Flag Counter

Pages

What is the difference in the function base_url () with the function site_url () in CodeIgniter?

CodeIgniter
Fungis base_url()and site_url()are two functions for retrieving web URLs in the CodeIgniter framework. Both of these functions can be used by activating the helper url first.

Function base_url()

the function base_url()will generate a basic url based on the configuration filled in config.phpSuppose the configuration is like this.
$config['base_url'] = 'http://petanikode.com/';
So, when we use a function base_url(), we get a value:
http://petanikode.com/

Function site_url()

As the name implies, the function site_url()will generate a URL or web address along with the index file. Suppose the web configuration is as follows.
$config['base_url'] = 'http://petanikode.com/';
$config['index_page'] = 'index.php';
So, when we use a function site_url(), we get a value:
http://petanikode.com/index.php

When base_url()and when to site_url()use?

After the results obtained from the function, we can guess for ourselves when the right time to use it.
The function is base_url()usually used to create a URL from a resource that is in the (root) web directory For example, make URL assets like the following.
Example URL Base Function
Meanwhile, functions are site_url()often used to make URLs to Controllers or in other words, this function is used to access certain Controllers.
Examples of its use are as follows:
Example of Using site_url ()
Another example use of the function site_url()to shift (redirect) .
Use Site URL to redirect

Conclusion

The function base_url()and function site_url()are the help functions of the helper url .
This function is used to retrieve the basic URL and web URL.
The function is base_url()used to build a url to access the current resource in the web root directory .
While the function is site_url()used to access certain controllers .
More or less, that's my conclusion. Maybe something is not right, please add it.

0 Komentar untuk "What is the difference in the function base_url () with the function site_url () in CodeIgniter?"

Silahkan berkomentar sesuai artikel

 
Template By Kunci Dunia
Back To Top