PHP Script – Cross Origin Resource Sharing (CORS) – Pre-flight response for the browser

This PHP snippet is to fulfill the pre-flight requirement for Cross Origin Resource Sharing (CORS) so browsers will access a resource from another domain to your server. This is useful for any APIs (restful or not), or any resource that will be called remotely. You can basically copy and paste this code. Brief explanation: Before…