I have a weird problem. I am making kinda my own framework like codeigniter and i have made a function equal to CI’s “base_url()” which in my case returns a string like: “http://www.example.com/”. My problem (which i have never heard off before) lies when I use my base_url() function to make links to css files and other navigation. So when I, in a view writes:
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/style.css" />
the actual link should be:
<link rel="stylesheet" type="text/css" href="http://www.example.com/css/style.css" />
My problem now is that the “string” returned from the function is correct when i look at the source code in Chrome and Firefox. But when i hover my mouse over it, the link, links to the following url instead:
http://example.com/%EF%BB%BFhttp://www.example.com/css/style.css
Can anyone explain why it would do this?
EDIT:
Im so sorry i forgat the source code for base_url():
function base_url($url_arguments = array()){
// Require config fil
include(dirname(__FILE__).'/../system/config.php');
// Generate link
$return_url = $config['base_url']; // http://www.example.com/
if(count($url_arguments) > 0){
$return_url .= "?";
foreach($url_arguments as $get => $value){
$return_url .= $get."=".$value.'&';
}
preg_match("/(.+?)&$/i", $return_url, $matches);
$return_url = $matches[1];
}
// Return link
return ($return_url);
}
Extra: my co-worker found in VIM that a tag named <feff> is appended in front of the link?
EFBBBF is the UTF-8 byte order mark. One has slipped into your config variable somehow. Edit the config file and remove it. If you’re reading the variable from a file and it’s legitimate for it to be there, trim it off in code.