Search code examples
web-applicationsfavicon

How to add a favicon.ico to a PHP website?


All I want to do is add a favicon.ico to my PHP website. Is there a simple PHP way of doing this or can it only be done with an HTML reference page?

Maybe using some jQuery/Ajax/JavaScript?


Solution

  • By default, most browsers will try to resolve the favicon.ico, even if you do not mention it in the HTML of the website (just make sure the file is in the root of the website directory). However, for compatibility, you should add the html code for it in the section of your web page.

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>