20

我知道这是一个愚蠢的问题,但我无法在任何地方找到答案。如果我使用 Codeigniter,我应该在哪里保存我的 favicon 文件以便它会在浏览器中弹出?或者文件中是否有我无法找到的配置选项?这真让我抓狂!

非常感谢您的帮助。

4

3 回答 3

33

这取决于您的组织。我通常将 favicon.gif 文件放在 web 根文件夹中,所以 URL 是yourdomain.com/favicon.gif

然后您必须将以下代码行添加到您的 HTML 中<head>

<link rel="icon" href="<?=base_url()?>/favicon.gif" type="image/gif">

假设在 CodeIgniter 中加载了 URL Helper。您可以通过加载它$this->load->helper('url');或将其添加到配置文件夹中的自动加载帮助器数组中。

于 2010-08-13T16:36:00.377 回答
3

您可以加载HTML 帮助程序<?php echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); ?><head>html 标记上使用。http://codeigniter.com/user_guide/helpers/html_helper.html#link_tag中的更多信息

于 2011-02-12T17:36:42.543 回答
2

我在我的代码中使用了它并且它工作正常

<pre>
<link rel="icon" href="<?php echo base_url(); ?>favicon.ico" type="image/gif">
</pre>
于 2014-06-28T07:38:33.623 回答