Are few of the server variables been added and few have been removed in PHP 7?

321 Views Asked by At

I am learning PHP from w3schools' PHP tutorial. I'm using PHP 7.0.13

While learning I come across the concept of Global Variables - Superglobals.

This is the page from where I'm learning Global Variables - Superglobals

Note : Please go to the above link to check the listing of server variables.

On this page I tried with all the server variables but I receive Notice as Undefined index for following few server variables :

  1. $_SERVER['HTTP_ACCEPT_CHARSET']
  2. $_SERVER['HTTPS']
  3. $_SERVER['REMOTE_HOST']
  4. $_SERVER['SCRIPT_URI']

For each of the above variables I tried following code. For example :

<!DOCTYPE html>
<html>
  <body>
    <pre>
    <?php
      echo $_SERVER['PATH_TRANSLATED'];//like this I tried for other three server variables also
    ?>
    </pre>
  </body>
</html>

Apart from this I also observed few new server variables are there in the array $_SERVRER when I tried to execute the code print_r($_SERVER);

So, my question is are few of the old server variables present in PHP5 have been removed in PHP7 and few others have been newly added?

I also tried to check in PHP Documentation but there also I couldn't get any idea about this.

So, please someone please clarify my doubts.

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

Content of $_SERVER is mainly created by web server, as documented here:

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

so PHP got very little to do here.