How can I throw other ideas from my mind while doing PhD? I have started doing PhD 3 months ago and I still don't have that much progress. What I found is that I spend more time on learning about web development, which I can choose not to do,  and this will make me focus more on my PhD and I'm sure I will do better. However, the problem is that web development is like an addiction for me. 

Web development is not like doing something else (it requires learning stuff so my mind will do a lot of hard work) and when I do that and come to do my research work in PhD I feel bored.

Now I decided to stop doing web development and focusing on PhD but how can I guarantee not to come back to that in 2 or 3 days?  I tried that one month ago and I found myself coming back to web development and not focusing that much on PhD.

Any ideas or suggestion on getting rid of this habit?
It sounds as though you are having a hard time finding motivation for pursuing your PhD. You don't mention the focus of your research, but one idea would be to modify the focus so that it aligns better with your addicting hobby of web-development (I'm not familiar with CS, so I have no idea how this would work in actual practice. Others will better be able to advise you on that.)

Become interested in your research. Assuming that you have compelling reasons for staying in your current area of research, you will need to have a genuine passion for the subject, or completing the PhD will become well-nigh impossible due to lack of motivation. See this article by Scott Young on how to learn boring subjects; his advice also holds for renewing interest in something. See the key points below.


Don't pick degree programs you hate. Although there are times when you may have to take courses you don't actually like, avoid a career made up of tasks and information you hate.
Don't confuse boring and difficult. It is easy to avoid something as boring, rather than admitting that it is difficult. 
Find the 'real-world' connections. Math isn't boring when you begin to see the connections and overall patterns--ditto for many other subjects/areas.
Discover the context. Take the time to explore the background, and understand why these [proofs, theorems, whatever] are important for where we are now. Young recommends reading Wikipedia articles on lunch-breaks for this purpose.
Make stories and pictures. Learning is a creative activity--the product is the intangible connections and stories in our minds. Mnemonics and stories can be interesting even when the subject is not. (Use this for the necessary but boring parts of research.)
Use the knowledge. Using even part of what you learn in a separate project will help cement the learning, and will also be interesting. (And anyway, isn't this part of the purpose of a PhD, to apply knowledge in new ways?)
Realize that not everything will be fun--more interest is better, even if relative differences still exist.