Aric Leather
Aric Leather

Reputation: 7

How to make a browser icon using PHP?

I'm aware that doing so in HTML is as simple as this:

<link rel="icon" href="/favicon.ico" />

However, I have a PHP site, in which:

DirectoryIndex index.php

to direct the user directly to the main page.

I can't seem to find a way to get a browser tab icon. What have I tried?

I tried to echo HTML inside index.php with the code, which didn't work. I also tried placing the line of code in some other working header HTML from within index.php. Google has nothing... literally.

The image is a .ico, called 'favicon.ico', is in root, and is recognized as a valid ico file.

Any help?

Upvotes: 0

Views: 1020

Answers (1)

EasyCo
EasyCo

Reputation: 2036

By default, you actually don't need anything in your HTML for a favicon. Simply having a valid favicon.ico in your root should be enough.

Sometimes, when changing favicon you need to clear your browser cache for that site. Also, try accessing the favicon.ico directly: http://example.com/favicon.ico and make sure you can load it.

Here's a good resource about favicons: HTML 5 Favicon - Support?

Upvotes: 2

Related Questions