How to Update the Current Browser URL

# UPDATE THE CURRENT URL IN BROWSER::
<script>

ChangeUrl = function(page, url) {

    if (typeof (history.pushState) != "undefined") {

        var obj = { Page: page, Url: url };

        history.pushState(obj, obj.Page, obj.Url);

        $('.breadcrumb-get-a-pro').attr('href', url);

    } else {

        alert("Browser does not support HTML5.");

    }

}

</script>

Meta Tags for Search Engine Optimization

Meta Tags for Search Engine Optimization
# Meta Tags used for seo::
<meta name="description" content="Stackofcodes is a blog for Learners, Developers, designers. "/>

<meta name="robots" content="noimageindex,noarchive,nosnippet"/>

<link rel="canonical" href="//www.stackofcodes.in/" />




<meta property="og:locale" content="en_US" />

<meta property="og:type" content="article" />

<meta property="og:title" content="Pricing | Kissmetrics" />

<meta property="og:description" content="Get, keep and grow more customers with Kissmetrics Customer Engagement Automation platform. Built for eCommerce marketers and product teams." />




<meta property="og:url" content="https://www.stackofcodes.in/" />

<meta property="og:site_name" content="Kissmetrics" />

<meta property="og:image" content="" />

<meta property="og:image:secure_url" content="" />

<meta property="og:image" content="" />

<meta property="og:image:secure_url" content="" />




<meta name="twitter:card" content="summary" />

<meta name="twitter:description" content="Stackofcodes is a blog for Learners, Developers, designers." />

<meta name="twitter:title" content="Stackofcodes" />

<meta name="twitter:image" content="" />


Check for Ajax Request in CodeIgniter

Check for Ajax Request in CodeIgniter:

The CodeIgniter Input Class Provides lots of  helper functions to deal with user inputs , security etc.this class is initialized automatically by the system so there is no need to do it manually.

I always recommend you to use this class instead using PHP Core Input Variables while dealing with forms and requests.

To check Ajax Request in CodeIgniter, we will use codeIgniter Output Class Method class is_ajax_request() , this function checks to see if the HTTP_X_REQUESTED_WITH server header has been set, if set response will be true otherwise false means it will returns a boolean response.

 

we can use

 $this->input->is_ajax_request()

from the input class:

if (!$this->input->is_ajax_request()) {
     exit('No direct script access allowed');
}

As, CodeIgniter Library::

is_ajax_request()

Returns:TRUE if it is an Ajax request, FALSE if not
Return type:bool

Checks to see if the HTTP_X_REQUESTED_WITH server header has been set, and returns boolean TRUE if it is or FALSE if not.

 

 

Source:
https://www.codeigniter.com/user_guide/libraries/input.html

Calculate the distance between two latitude & longitude

Calculate the distance between two latitude & longitude

function distance($lat1, $lon1, $lat2, $lon2, $unit){

      $theta = $lon1 - $lon2;

      $dist  = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));

      $dist  = acos($dist);

      $dist  = rad2deg($dist);

      $miles = $dist * 60 * 1.1515;

      $unit  = strtoupper($unit);

      if ($unit == "K") {

           return ($miles * 1.609344);

      }else if ($unit == "N") {

           return ($miles * 0.8684);

      }else {

           return $miles;

     }

}