WordPress Code Snippets

A fresh mix of code snippets and tutorials

PHP Check if Request is HTTPS


Here we have a simple and effective PHP function that checks whether or not HTTPS (via SSL) is used for the current request.

This function checks the value of the $_SERVER['HTTPS'] variable to see if it contains a non-empty value that is not equal to off. If both of these conditions are true, OR if the $_SERVER['SERVER_PORT'] variable is set to 443, the function evaluates to true. So we can use this function like so:

This bit of logic basically checks the value of shapeSpace_check_https() so that specific functionality may be applied in either case (i.e., HTTPS on or HTTPS off). Easy peasy!

Show Support

Like our new Facebook Page to show support!