How to set Favicon in Codeigniter

大城市里の小女人 提交于 2019-11-29 16:39:49

问题


I know this is a stupid question, but I can't find the answer anywhere. If I'm using Codeigniter, where do I save my favicon file so that it will pop up in the browser? Or is there a config option in the files that I haven't been able to find yet? This is driving me crazy!

Thanks a lot for the help.


回答1:


It depends on your organization. I usually put the favicon.gif file in the web root folder, so the URL would be yourdomain.com/favicon.gif

Then you have to add the following line of code into your HTML <head>:

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

Assuming that the URL Helper is loaded in CodeIgniter. You can load it via $this->load->helper('url'); or add it into the autoload helper array in your config folder.




回答2:


You could load the HTML helper and use <?php echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); ?> on the <head> html tag. More information in http://codeigniter.com/user_guide/helpers/html_helper.html#link_tag




回答3:


I have used this in my code and its working fine

<pre>
<link rel="icon" href="<?php echo base_url(); ?>favicon.ico" type="image/gif">
</pre>


来源:https://stackoverflow.com/questions/3478720/how-to-set-favicon-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!