You can learn to play guitar online. There are many free lessons that are available however they are basics and they don't teach you advanced techniques. It's always good to buy a good guitar course.
I have been playing guitar for 10 years now and I found some interesting online guitar lessons that you can choose.
I think they are the best. If you are really interested in becoming a guitar player, you can choose the following guitar courses with nominal fees below:
Guitar notes Master
Guitar burning speed
You won't regret your decision of buying one course because a personal guitar teacher will charge three times more than this.