Virtualhost in Xampp localhost windows machine

Steps to follow

  1. Open c:\Windows\System32\drivers\etc\hosts file
  2. Uncomment the 127.0.01  localhost and add new domain names which you would like to add example ( 127.0.0.1  domain1 , 127.0.0.1 site2 )
  3.  Now open c:\xampp\apache\conf\extra\httpd-vhosts.conf file
  4.  Add the below code in the httpd-vhosts.conf file
  1. <VirtualHost *:80>
  2. DocumentRoot “C:/xampp/htdocs/site1”
  3. ServerName site1
  4. </VirtualHost>

5. Now open c:\xampp\apache\conf\httpd.conf file

  6. Remove # comment this line “Include conf/extra/httpd-vhosts.conf”
  7.  Restart Apache server
  8. Create folder name site1 or any domain which you created in the host file and test it using any sample code by running the url using your domain name “http://site1 or http://domain etc”

 

Advertisements

Get Country currency code by user IP address in php

$ip=$_SERVER[‘REMOTE_ADDR’];
$countrycode = “http://www.geoplugin.net/json.gp?ip=$ip&#8221;;
$ip_data = @json_decode(file_get_contents(“http://www.geoplugin.net/json.gp?ip=&#8221;.$ip));

if($ip_data && $ip_data->geoplugin_countryName != null){
$result[‘geoplugin_countryName’] = $ip_data->geoplugin_countryName;
$result[‘geoplugin_currencyCode’] = $ip_data->geoplugin_currencyCode;
}

echo $result[‘geoplugin_currencyCode’];

Currency Converter in PHP

$encode_amount = 1;
$amount = 100;
$from_Currency = ‘INR’;
$to_Currency = ‘USD’;

$get = file_get_contents(“https://www.google.com/finance/converter?a=$encode_amount&from=$from_Currency&to=$to_Currency&#8221;);
$get = explode(“<span class=bld>”,$get);
$get = explode(“</span>”,$get[1]);
$rate= preg_replace(“/[^0-9\.]/”, null, $get[0]);
$converted_amount = $amount*$rate;
$data = array( ‘rate’ => $rate, ‘converted_amount’ =>$converted_amount, ‘from_Currency’ => strtoupper($from_Currency), ‘to_Currency’ => strtoupper($to_Currency));

 

Array
(
    [rate] => 0.0147
    [converted_amount] => 1.47
    [from_Currency] => INR
    [to_Currency] => USD
)