$GLOBAL - Used to access global variables from anywhere in the PHP script

                
                    <?php 
                    $x = 75;
                    $y = 25; 
                    
                    function addition() {
                      $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
                    }
                    
                    addition();
                    echo $z;
                    ?>
                
                

$_SERVER - Holds information about headers, paths, and script locations

                
                    <?php 
                    echo $_SERVER['PHP_SELF'];
                    echo "<br>";
                    echo $_SERVER['SERVER_NAME'];
                    echo "<br>";
                    echo $_SERVER['HTTP_HOST'];
                    echo "<br>";
                    echo $_SERVER['HTTP_REFERER'];
                    echo "<br>";
                    echo $_SERVER['HTTP_USER_AGENT'];
                    echo "<br>";
                    echo $_SERVER['SCRIPT_NAME'];
                    ?>
                
                

$_REQUEST - Used to collect data after submitting an HTML form

                
                    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
                        Name: <input type="text" name="fname">
                        <input type="submit">
                      </form>
                      
                      <?php
                      if ($_SERVER["REQUEST_METHOD"] == "POST") {
                        // collect value of input field
                        $name = htmlspecialchars($_REQUEST['fname']); 
                        if (empty($name)) {
                          echo "Name is empty";
                        } else {
                          echo $name;
                        }
                      }
                      ?>
                
                

$_POST - Used to collect form data after submitting an HTML form. Also used to pass variables

                
                    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
                        Name: <input type="text" name="fname">
                        <input type="submit">
                      </form>
                      
                      <?php
                      if ($_SERVER["REQUEST_METHOD"] == "POST") {
                        // collect value of input field
                        $name = $_POST['fname']; 
                        if (empty($name)) {
                          echo "Name is empty";
                        } else {
                          echo $name;
                        }
                      }
                      ?>
                
                

$_GET - Collect data sent in the URL

                
                    <a href="test_get.php?subject=PHP&web=W3schools.com">Test $GET</a>