$PHP_SELF, from what i have seen of it, and now tested only returns the file name, not the host, not the protocol
eg.
if your accessing the file http://www.testserver.com/index.php
and it contains echo $PHP_SELF;
it will only return /index.php
so my advice to you is to start from scratch.
<?
$page = $_SERVER['PHP_SELF']; // returns to you what i just explained
$domain = $_SERVER['HTTP_HOST']; // returns www.testserver.com
$protocol = "https"; // sets your secure protocol
$secure_server_ssl = $protocol."://".$domain.$page;
?>
hope this helps