Enable CORS on CodeIgniter Controller PHP

How to Enable CORS on CodeIgniter Controller PHP. Learn with a Simple Constructor Method for your PHP Controller.

This is a Short Snippet for Code Igniter to Enable CORS on Controller. 

 

public function __construct()
{
    header('Access-Control-Allow-Origin: *');
    header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
    parent::__construct();
}