我有一个奇怪的问题。我正在制作自己的框架,例如 codeigniter,并且我制作了一个等于 CI 的“base_url()”的函数,在我的情况下它返回一个字符串,例如:“http://www.example.com/”。我的问题(我以前从未听说过)在于我使用 base_url() 函数创建指向 css 文件和其他导航的链接时。因此,当我在视图中写道:
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/style.css" />
实际链接应该是:
<link rel="stylesheet" type="text/css" href="http://www.example.com/css/style.css" />
我现在的问题是,当我查看 Chrome 和 Firefox 中的源代码时,从函数返回的“字符串”是正确的。但是当我将鼠标悬停在它上面时,链接会链接到以下网址:
http://example.com/%EF%BB%BFhttp://www.example.com/css/style.css
谁能解释它为什么会这样做?
编辑:很抱歉,我忘记了 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);
}
额外:我的同事在 VIM 中发现<feff>
链接前面附加了一个名为的标签?