SSL certificate problem: self signed certificate in certificate chain

Go to and download the pem file and save in your php installation directory ( make sure while saving it retains the extension and not saved as a text file )

Now, open your php.ini file, scroll to the bottom and add the following line:


Replace D:\xampp\php\cacert.pem with the actual path.

WebView-based Applications for Web Developers

Getting started with the Android WebView is fairly simple, whether you want load a remote URL or display pages stored in your app.

This tutorial walks you through creating a new Android Project, adding a WebView, loading a remote URL, and then loading a local HTML page.

Getting user location from an IP address

Want to retrieve information like the city, state, and country of a visitor from their IP address?

PHP example:

$details = json_decode(file_get_contents("{$ip}"));
echo $details->city;


jQuery example:

$.get("", function(response) {
}, "jsonp");



PHP stdClass Object to Array

This post defines two ultra simple recursive function to convert multidimensional Objects to Arrays and multidimensional Arrays to Objects.

NOTE: If this function is called as a class method, then the return line needs to be replaced with the following…

return array_map( array($this, __FUNCTION__), $d );

PHP implementation of Google Analytics

As you know the main implementation of GA is a JavaScript library which is all well and good as long as

  1. The user has JavaScript enabled
  2. Everything we want to track outputs html (so the GA code runs)

If we ever need to track page views and other events for a client who insists we catch that small minority of users with JavaScript turned off then we can us this

It can also be used in AJAX scripts and code that doesn’t actually display any html such as CSV export scripts.

Get JSON from remote domain using jQuery when CORS not possible

The same origin policy means you cannot get data from a different server unless it allows cross-origin resource sharing (CORS).

To get round this restriction we can use the JSONP function of jQuery, however we do need to wrap the returning data in a javascript function specified by the initial request.

The 2 basic bits of code required are…


        url: '',
        dataType: 'jsonp',
        success: function( data ){
        console.log( data ) ;


echo $_GET['callback'] . '(' .$aaMyJSONData . ');' ;

If the server allows CORS, you can send back the required headers using the following code:

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day