You are here
Home > Php > Currency Convertor as Per Geo Location in PHP

Currency Convertor as Per Geo Location in PHP


Hello Friends, today we are going to see a script for currency convertor as per geo location in php. We are going to use Free plan of currencylayer api for currency rates and geoplugin api for geo location. currencylayer’s free version api only does not support currency conversion and we cannot change base currency other than USD. So, here we going to utilize free version for conversion. But we have to use it smartly as it gives only 250 request / month in free plan. You can request once, twice or maximum eight times in a day and store currency rates in database and use database value for conversion instead of directly sending request to currencylayer. In this way 250 request is enough for whole month. But here I am only going to explain how to use currencylayer api, how to convert, how to get geo location, rest you can customize according to your need. So let’s start coding


Here in the above code you can see two function one is ipInfo() and another one is convert(). ipinfo converts user’s ip to location as well as gives currency code of the location and convert function converts given amount one currency to another currency.



Download Script


Thanks friends
Please don’t forget to share if you find this helpful

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.