mirror of
https://github.com/bcit-ci/CodeIgniter.git
synced 2025-02-20 11:13:29 +08:00
...
parent
0953d6824d
commit
d0a0112493
21
Get-domain-name.md
Executable file
21
Get-domain-name.md
Executable file
@ -0,0 +1,21 @@
|
||||
I needed to get the domain name only based on the base_url() function.
|
||||
I added the following function to the url_helper.php :
|
||||
|
||||
/**
|
||||
* Get domain
|
||||
*
|
||||
* Return the domain name only based on the "base_url" item from your config file.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function getDomain()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return preg_replace("/^[\w]{2,6}:\/\/([\w\d\.\-]+).*$/","$1", $CI->config->slash_item('base_url'));
|
||||
}
|
||||
|
||||
So you can use it in your code in the same manner than site_url() or base_url()
|
||||
|
||||
Hope this help somebody !
|
Loading…
x
Reference in New Issue
Block a user