0

I've a strange comportement while i'm trying to detect if HTTPS is enabled or not:

$ssl=(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
$expected=$ssl.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

echo $ssl.'<br/>';
echo $ssl.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'<br/>';
echo $ssl.'<br/>';
echo $ssl.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'<br/>';

The result:

http
https://<MYDOMAIN>/beta/test.php
http
http<MYDOMAIN>/beta/test.php

Why, on the second line, it says httpS but just before and after http ?

Running PHP: 7.4.20 (OPcache enabled)

Thank you

Amaury
  • 1

1 Answers1

0

Try resetting the cache:

opcache_reset(); // put this line before your code

// code...

Navigate to the file. Then remove the line and try your test again.

Prince Dorcis
  • 955
  • 7
  • 7
  • No, not working already tried to invalidate this file and reset opcache, also restarted php (running php-fpm), always same comportement – Amaury Jun 24 '21 at 13:49