I want to add a static_url and make_url method in Config class and url_helper helper, so that I can make url in the view pages.
PHP Code:
class MY_Config extends CI_Config {
public function __construct()
{
parent::__construct();
}
public function static_url($uri = '', $protocol = NULL)
{
$static_url = $this->slash_item('static_url');
if (isset($protocol))
{
$static_url = $protocol.substr($static_url, strpos($static_url, '://'));
}
return $static_url.ltrim($this->_uri_string($uri), '/');
}
public function make_url($name, $uri = '', $protocol = NULL)
{
$make_url = $this->slash_item($name);
if (isset($protocol))
{
$make_url = $protocol.substr($make_url, strpos($make_url, '://'));
}
return $make_url.ltrim($this->_uri_string($uri), '/');
}
}
PHP Code:
if ( ! function_exists('static_url'))
{
function static_url($uri = '', $protocol = NULL)
{
return get_instance()->config->static_url($uri, $protocol);
}
}
if ( ! function_exists('make_url'))
{
function make_url($name, $uri = '', $protocol = NULL)
{
return get_instance()->config->make_url($name, $uri, $protocol);
}
}
But when test this, error occurs:
A PHP Error was encountered
Severity: Error
Message: Call to undefined method CI_Config:
tatic_url()
Filename: helpers/MY_url_helper.php
Line Number: 8
Backtrace:
-------------------
why the static_url cannot find the new method in extended Config class ??