SSL check with PHP

Apr 04, 2015, by php team

We have demonstrated the simple way to check the SSL status of server.
First thing we need is to find the server SSL status with the PHP by using $_SERVER[‘HTTPS’].
The above statement returns “on”/”off” according to the server.
Some server can also returns the empty results.It’s better way to check the return value is empty also.
The below example illustrates all those things simply.

<pre>

<?php

$protocol_mode = $_SERVER[‘HTTPS’];

if ( !empty($protocol_mode) && $protocol_mode == “on”) {
echo “Yes it’s HTTPS…!!”;
}else{
echo “No it’s not HTTPS…!!”;
}

?>

</pre>