Dynamic unread count Favicon in PHP

Dynamic Unread count favicon in PHPGmail has just launched small but really useful feature in Gmail Labs. Dynamic Favicon showing unread email counts directly in your browser tab icon. If your browser window has lots and lots of tabs open at anytime, this might be really a wonderful feature that lets user know of any unread item.

Here is a small and powerful script in PHP that lets you create your own Dynamic favicon. We will use PHP GD library to manipulate the favicon image and add text into it.

Below is the simple script that reads a favicon image add add some text character on it.

File: favicon.php

The above code is pretty much self explanatory. We read a character from GET request and add it into the favicon image. Note here that we are using a template favicon image which me modify. You can place any favicon of your choice near favicon.php file.

Download Source Code

Click here to download complete source code (ZIP, 3kb)

Online Demo

Click here to view online demo


  • huarong 17 February, 2011, 6:44

    We can make some favicon_1.png favicon_2.png … favicon_9.png
    and use javascript to set it.

  • Rob Odil 24 June, 2011, 21:42

    You can then use a link tag to set the png as your favicon like this:

  • sagar 24 January, 2013, 7:55

    thanksssss….. help full ….for me……

  • phlp 1 May, 2013, 13:07

    why do you definde $bg and don’t use it anywhere?

  • creatives infotech 5 March, 2014, 18:05

    Hey You are really great, You show a really great method to use counter favicon.

Leave a Reply

Your email address will not be published. Required fields are marked *


To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]